bigquery concat布尔值数组

时间:2019-02-07 02:35:55

标签: google-bigquery

尝试运行此查询,并且“授权”字段出现问题:

SELECT 

ARRAY_TO_STRING(ARRAY(SELECT permission FROM t.protopayload_auditlog.authorizationInfo), ',') permissions,
ARRAY_TO_STRING(ARRAY(SELECT granted FROM t.protopayload_auditlog.authorizationInfo), ',') granted,
ARRAY_TO_STRING(ARRAY(SELECT resource FROM t.protopayload_auditlog.authorizationInfo), ',') resource,

protopayload_auditlog.requestMetadata.callerSuppliedUserAgent AS agent,
timestamp,
severity,
resource.labels.bucket_name as name_of_bucket,
protopayload_auditlog.authenticationInfo.principalEmail

FROM 
`mytable` t

授予的是布尔值而不是字符串,并且我收到此错误:

No matching signature for function ARRAY_TO_STRING for argument types: ARRAY, STRING. Supported signatures: ARRAY_TO_STRING(ARRAY, STRING, [STRING]); ARRAY_TO_STRING(ARRAY, BYTES, [BYTES]) at [6:1]

1 个答案:

答案 0 :(得分:2)

您应将布尔值CAST布尔值转换为STRING,如下例所示

ARRAY_TO_STRING(ARRAY(SELECT CAST(granted AS STRING) FROM t.protopayload_auditlog.authorizationInfo), ',') granted,