错误:在BigQuery中无法访问类型为ARRAY >的值的字段元素

问题描述 投票:2回答:1

我从pyspark将df导出到BigQuery。 df具有包含数组元素的列,我如何将数组转换为串联字符串?每当我尝试查询导出的BigQuery表的数组列时,都会收到以下错误。

Error: Cannot access field element on a value with type ARRAY<STRUCT<element STRING>> 

下面是pyspark中的df,该df已导出到BigQuery:

+-----------+----------+-------------------+------------------+
| antecedent|consequent|         confidence|              lift|
+-----------+----------+-------------------+------------------+
|[19, 6, 39]|      [44]|  0.418945963975984|10.602038775664845|
|[19, 6, 39]|      [35]|0.47298198799199465| 7.423073393311932|
|[19, 6, 39]|     [322]|   0.47631754503002|4.6520592549063995|
|[19, 6, 39]|     [308]| 0.4496330887258172| 5.856259667533207|
|[19, 6, 39]|     [345]| 0.5196797865243495|5.4970336458402285|

下面是BigQuery中的表的架构,该架构是在将df从pyspark导出到bigquery后生成的:

enter image description here

当以表格形式查看时,外观如下:

enter image description here

sql google-cloud-platform pyspark google-bigquery google-cloud-dataproc
1个回答
0
投票

您能否提供查询的SQL语句?我猜您正在尝试直接选择BigQuery中不允许的数组列。您需要展平数组,请参见此doc中的更多详细信息。

© www.soinside.com 2019 - 2024. All rights reserved.