WRITE_TRUNCATE in Bigquery



我试图使用write_truncate截断 Bigquery 中的表,但它没有发生,而是像write_append一样工作。它附加数据但不截断表。

有人可以帮助解决问题吗?

我的代码:

with beam.Pipeline(options=Pipeline options()) as p:
read=(p|"Read BQ">>beam.io.Read(beam.io.BigQuerySource(
query='select empid from''`PRoject_Id.data_set.emp_details`',
use_standard_sql=True))|"process">>beam.Map(lambda ele:{'EMPID':ele['EMPID']})|
"Write">>beam.io.WriteToBigQuery(
'PROJECT_ID:data_set.emp_out',
schema='EMPID:STRING',
write_disposition=beam.io.BigQueryDisposition.WRITE_TRUNCATE,
create_dispositiom=beam.io.BigQueryDisposition.CREATE_IF_NEDED))
if __name__="__main__":
run().wait_until_finish()

对于流式处理管道,不支持流式处理管道WRITE_TRUNCATE,如此处所述。

For streaming pipelines WriteTruncate can not be used.

可以将管道转换为 Batch 并使用WRITE_TRUNCATE选项。要将写入转换为批处理,您可以将method参数设置为FILE_LOADS。默认此参数设置为STREAMING_INSERTS

最新更新