Google bigquery 在数据流中自动检测BigQuery架构?

Google bigquery 在数据流中自动检测BigQuery架构?,google-bigquery,google-cloud-dataflow,apache-beam,Google Bigquery,Google Cloud Dataflow,Apache Beam,是否可以在数据流中使用等效的 i、 e.我们是否可以在不指定模式的情况下将数据加载到BQ表中,这相当于我们如何使用--autodetect从CSV加载数据 ()我不确定是否要阅读BQ,但对于编写,我认为这样的东西可以在最新的java SDK上使用 .apply("WriteBigQuery", BigQueryIO.Write .withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_NEVER) .to(o

是否可以在数据流中使用等效的

i、 e.我们是否可以在不指定模式的情况下将数据加载到BQ表中,这相当于我们如何使用
--autodetect
从CSV加载数据


()

我不确定是否要阅读BQ,但对于编写,我认为这样的东西可以在最新的java SDK上使用

.apply("WriteBigQuery", BigQueryIO.Write
    .withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_NEVER)
    .to(outputTableName));


Note: BigQuery Table must be of the form: <project_name>:<dataset_name>.<table_name>.
.apply(“WriteBigQuery”,BigQueryIO.Write
.withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE\u NEVER)
.to(outputTableName));
注意:BigQuery表的格式必须为::。。
如果您在pcollection中使用as对象(在数据流后端应该表现得很好),您可能可以使用我以前编写的util。它将在运行时根据对protobuffer描述符的检查,将protobuffer的模式解析为BigQuery模式

我很快把它上传到了,它是WIP,但您可能可以使用它,或者受到启发,使用Java反射编写类似的东西(我可能会在某个时候自己编写)

您可以按如下方式使用util:

TableSchema schema = ProtobufUtils.makeTableSchema(ProtobufClass.getDescriptor());
enhanced_events.apply(BigQueryIO.Write.to(tableToWrite).withSchema(schema)
            .withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_IF_NEEDED)
            .withWriteDisposition(BigQueryIO.Write.WriteDisposition.WRITE_TRUNCATE));

其中,create处置将使用指定的架构创建表,Protobuf类是使用Protobuf架构和proto编译器生成的类。

请澄清您的具体问题或添加其他详细信息,以突出显示您所需的内容。正如目前所写的,很难准确地说出你在问什么。请参阅页面以获取澄清此问题的帮助。我们可以在不指定架构的情况下写入BQ吗?但这仅在表已经存在的情况下有效-即
BigQueryDisposition.CREATE\u NEVER:如果不存在,则写入失败。
是的,在这种情况下,我们需要一个存在的表,因为我们正在尝试检测现有表的架构。如果目标/问题是定义一个方案并基于java数据类型创建一个表,那么我认为我们不支持它?物体?