使用本地文件通过Java库加载Google BigQuery表

jes*_*and 3 google-bigquery

有没有办法通过BigQuery Java库从本地CSV文件加载表?当我尝试将本地文件URI传递给JobConfigurationLoad.setSourceUris()时,我收到错误"源URI必须是Google存储位置".

相关的,如果我需要先将文件上传到Google云端存储,如果我将文件加载到BigQuery后立即从云存储中删除该文件,我会收取哪些费用?

Ale*_*ahi 5

使用Bigquery插入方法:

public Insert insert(String projectId, com.google.api.services.bigquery.model.Job content,
        com.google.api.client.http.AbstractInputStreamContent mediaContent)
Run Code Online (Sandbox Code Playgroud)

您有2个AbstractInputStreamContent实现:FileContent,InputStreamContent

例如:

val content = FileContent("application/octet-stream", new File("csv","data.csv")
val insertReq = bigquery.jobs().insert(PROJECT_ID, insertJob, content))
Run Code Online (Sandbox Code Playgroud)