Assigned
Status Update
Comments
va...@google.com <va...@google.com>
ja...@google.com <ja...@google.com> #2
Hello,
This issue report has been forwarded to the Cloud BigQuery Product team so that they may investigate it, but there is no ETA for a resolution today. Future updates regarding this issue will be provided here.
Description
The customer is trying to use parameterized queries with Python Client Library for BigQuery and is receiving invalid results when the parameter is an array and its value is an empty array.
An unexpected behavior occurs and it may result in subtle bugs trivially introduced without being noticed, which can result in multiple issues downstream, up to and including data corruption and/or data loss during processing.
The issue also occurs with a small repro in Go language, it is likely language-independent. Here is a minimal reproduction in Python:
Actual output:
array_len: None
Expected output:
array_len: 0
Passing non-parameterized query works as expected:
SELECT ARRAY_LENGTH([]) as array_len
- the result is0
.It behaves as if the parameter was passed as
NULL
(in which caseARRAY_LENGTH
returnsNULL
).The workaround is to use the
COALESCE
function - although it may be difficult for customers to come up with and remember to use it every time. The above query can be written as:The workaround is insufficient for the customer for reasons given above.