2012-08-01 3 views
3

BigQuery Java 라이브러리를 통해 로컬 CSV 파일에서 테이블을로드하는 방법이 있습니까? JobConfigurationLoad.setSourceUris()에 로컬 파일 URI를 전달하려고 할 때 "원본 URI는 Google 저장소 위치 여야합니다."라는 오류 메시지가 나타납니다.로컬 파일이있는 Java 라이브러리를 통해 Google BigQuery 테이블로드

관련하여 먼저 파일을 Google Cloud Storage에 업로드해야하는 경우 클라우드 스토리지에서 파일을 BigQuery로로드 한 직후 파일을 삭제하면 어떻게 청구됩니까?

답변

1

멀티 파트 MIME 요청을 사용하여 파일을 직접 업로드 할 수 있습니다 ... bigquery import docs here을 참조하십시오. 자바에는 예제가 없지만, 파이썬에는 비교적 적응하기 쉬운 예제가있다. 그러나 매우 큰 파일을 다루는 경우 먼저 파일을 Google Cloud Storage에 업로드하는 것이 좋습니다.

파일을 Google Cloud Storage에 준비한 다음 삭제하면 최대 24 시간 동안 저장 용량이 청구될 수 있습니다 (확실치는 않지만 저장 용량은 24 시간을 넘지 않습니다).).

5

사용 BigQuery에 삽입 방법 :

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

당신은 AbstractInputStreamContent의 2 implems 있습니다 포함한 FileContent을 InputStreamContent

예를 들어

:

val content = FileContent("application/octet-stream", new File("csv","data.csv") 
val insertReq = bigquery.jobs().insert(PROJECT_ID, insertJob, content)) 
관련 문제