Google bigquery 我可以为Spark筛选BigQuery连接器返回的数据吗?

Google bigquery 我可以为Spark筛选BigQuery连接器返回的数据吗?,google-bigquery,google-cloud-dataproc,Google Bigquery,Google Cloud Dataproc,我已经修改了上的说明,使用PySpark从私有BigQuery对象提取数据。我正在Dataproc上运行代码。所讨论的对象是一个基数大于5亿行的视图。当我发表这项声明时: table_data=spark.sparkContext.newAPIHadoopRDD( 'com.google.cloud.hadoop.io.bigquery.JsonTextBigQueryInputFormat', 'org.apache.hadoop.io.LongWritable', 'com.google.g

我已经修改了上的说明,使用PySpark从私有BigQuery对象提取数据。我正在Dataproc上运行代码。所讨论的对象是一个基数大于5亿行的视图。当我发表这项声明时:

table_data=spark.sparkContext.newAPIHadoopRDD(
'com.google.cloud.hadoop.io.bigquery.JsonTextBigQueryInputFormat',
'org.apache.hadoop.io.LongWritable',
'com.google.gson.JsonObject',
conf=conf)
在作业输出中,我看到:

Bigquery connector version 0.10.7-hadoop2
Creating BigQuery from default credential.
Creating BigQuery from given credential.
Using working path: 'gs://dataproc-9e5dc592-1a35-42e6-9dd6-5f9dd9c8df87-europe-west1/hadoop/tmp/bigquery/pyspark_input20181108091647'
Estimated number of shards < desired num maps (0 < 93); clipping to 0.
Computed '2' shards for sharded BigQuery export.
Table 'projectname:datasetname.viewname' to be exported has 0 rows and 0 bytes
Estimated number of shards < desired num maps (0 < 93); clipping to 0.
Computed '2' shards for sharded BigQuery export.
Table 'projectname:datasetname.viewname' to be exported has 0 rows and 0 bytes
我觉得奇怪的是,碎片的数量估计为0。我已经查看了这里执行的一些代码(),上面的消息是从中记录的。给定
numShards=0
我假设
numTableBytes=0
这意味着函数调用:

tableToExport.getNumBytes();
()

返回0,我假设原因是我正在访问的对象是一个视图,而不是一个表。我是在搞什么鬼还是在白费力气


更新2。。。 为了验证我的理论(如上所述),即作为视图的源对象导致了问题,我做了以下工作:

在与我的dataproc集群相同的项目中创建了一个表 将数据插入其中 已提交dataproc作业以读取表并输出行数 代码如下:

conf={
#输入参数。
'mapred.bq.project.id':项目
,'mapred.bq.gcs.bucket':bucket
,'mapred.bq.temp.gcs.path':输入目录
,'mapred.bq.input.project.id':'myproject'
,'mapred.bq.input.dataset.id':'jt_test'
,'mapred.bq.input.table.id':jttable1
}
表_data=spark.sparkContext.newAPIHadoopRDD(
'com.google.cloud.hadoop.io.bigquery.JsonTextBigQueryInputFormat',
'org.apache.hadoop.io.LongWritable',
'com.google.gson.JsonObject',
conf=conf)
打印('got table_data')
打印(表_data.toDF().head(10))
打印('row tally={}'。格式(table_data.toDF().count())
当我运行dataproc pyspark作业时,输出如下:

Estimated number of shards < desired num maps (0 < 93); clipping to 0
8/11/08 14:59:26 INFO <cut> Table 'myproject:jt_test.jttable1' to be exported has 1 rows and5 bytes
got table_data
[Row(_1=0, _2=u'{"col1":"foo"}')]
row tally=1
Table 'dh-data-dev-53702:jt_test.v_jtview1' to be exported has 0 rows and 0 bytes
运行相同的作业,但这次使用视图而不是表
conf={
#输入参数。
'mapred.bq.project.id':项目
,'mapred.bq.gcs.bucket':bucket
,'mapred.bq.temp.gcs.path':输入目录
,'mapred.bq.input.project.id':'myproject'
,'mapred.bq.input.dataset.id':'jt_test'
,'mapred.bq.input.table.id':v_jtview1
}
当我运行dataproc pyspark作业时,输出如下:

Estimated number of shards < desired num maps (0 < 93); clipping to 0
8/11/08 14:59:26 INFO <cut> Table 'myproject:jt_test.jttable1' to be exported has 1 rows and5 bytes
got table_data
[Row(_1=0, _2=u'{"col1":"foo"}')]
row tally=1
Table 'dh-data-dev-53702:jt_test.v_jtview1' to be exported has 0 rows and 0 bytes
就这样!没有更多输出,作业仍在运行,与我上面解释的完全相同。它实际上是挂着的


这似乎是BigQuery连接器的一个限制-我不能使用它从视图中使用。

为了结束这里的循环,jamiet@在评论中确认根本原因是BigQuery不支持从视图导出,它只支持从表导出。

分片导出支持新的BigQuery导出API。通过设置
mapred.bq.input.sharded.export.enable=false
property,您可以在当前设置中禁用它。谢谢Igor。我试过了,现在看到了:
java.io.IOException:使用表myproject:jt_test.v_jtview1@1591691413249由于其类型,此操作不允许使用。尝试使用另一个类型为table的表。
看起来好像我不能使用视图:(!!!有可能有一天会更改吗?;)只要BigQuery添加对该功能或类似功能的支持,它就会在连接器中可用。