第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 python 將嵌套的 BigQuery 數(shù)據(jù)導(dǎo)出到云存儲

使用 python 將嵌套的 BigQuery 數(shù)據(jù)導(dǎo)出到云存儲

喵喵時光機 2021-12-17 16:45:42
嘗試將 bigquery 數(shù)據(jù)導(dǎo)出到存儲,但出現(xiàn)錯誤“400 無法對嵌套架構(gòu)執(zhí)行操作。字段:event_params”。下面是我的代碼:from google.cloud import bigqueryclient = bigquery.Client()os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/Users/Nitin/Desktop/big_query_test/soy-serty-897-ed73.json"bucket_name = "soy-serty-897.appspot.com"project = "soy-serty-897"dataset_id = "analytics_157738"table_id = "events_20190326"destination_uri = 'gs://{}/{}'.format(bucket_name, 'basket.csv')dataset_ref = client.dataset(dataset_id, project=project)table_ref = dataset_ref.table(table_id)extract_job = client.extract_table(    table_ref,    destination_uri,    # Location must match that of the source table.    location='US')  # API requestextract_job.result()  # Waits for job to complete.print('Exported {}:{}.{} to {}'.format(    project, dataset_id, table_id, destination_uri))
查看完整描述

2 回答

?
至尊寶的傳說

TA貢獻1789條經(jīng)驗 獲得超10個贊

在 BigQuery導(dǎo)出限制中,提到 CSV 不支持嵌套和重復(fù)數(shù)據(jù)。因此,嘗試導(dǎo)出到 Avro 或 JSON:


from google.cloud import bigquery

client = bigquery.Client()

bucket_name = 'your_bucket'

project = 'bigquery-public-data'

dataset_id = 'samples'

table_id = 'shakespeare'


destination_uri = 'gs://{}/{}'.format(bucket_name, '<your_file>')

dataset_ref = client.dataset(dataset_id, project=project)

table_ref = dataset_ref.table(table_id)

configuration = bigquery.job.ExtractJobConfig()

#For AVRO

#configuration.destination_format ='AVRO'

#For JSON

#configuration.destination_format ='NEWLINE_DELIMITED_JSON'


extract_job = client.extract_table(

table_ref,

destination_uri,

job_config=configuration,

location='US')

extract_job.result()

希望能幫助到你。


查看完整回答
反對 回復(fù) 2021-12-17
?
手掌心

TA貢獻1942條經(jīng)驗 獲得超3個贊

現(xiàn)在無法測試,但也許這有效:


from google.cloud import bigquery as bq

ejc = bq.ExtractJobConfig()

ejc.destination_format='NEWLINE_DELIMITED_JSON'

extract_job = client.extract_table(

    table_ref,

    destination_uri,

    # Location must match that of the source table.

    location='US',

    job_config=ejc)  # API request

這個想法是使用 JSON 而不是 CSV,以便您支持嵌套數(shù)據(jù)。


查看完整回答
反對 回復(fù) 2021-12-17
  • 2 回答
  • 0 關(guān)注
  • 176 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號