我试图使用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()发布于 2020-06-04 18:15:22
在流式管道的情况下,不支持作为文档记录的here的WRITE_TRUNCATE。
For streaming pipelines WriteTruncate can not be used.您可以将流水线转换为批处理并使用WRITE_TRUNCATE选项。要将写入转换为批处理,可以将method参数设置为FILE_LOADS。默认情况下,此参数设置为STREAMING_INSERTS。
https://stackoverflow.com/questions/62189870
复制相似问题