fix: emit NULL literal for nil values in SelectInlineResults#9336
Merged
Conversation
BigQuery's Go client rejects nil parameter values in `bigquery.QueryParameter`. When a metrics aggregation query with comparison time ranges returns NULL dimension values, `getArgExpr` was emitting a `?` placeholder with a nil arg, causing "bigquery: nil parameter" errors. Emit a SQL `NULL` literal instead and skip appending nil to the args slice so positional parameter alignment is preserved. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
pjain1
reviewed
Apr 30, 2026
| } | ||
|
|
||
| func getArgExpr(val any, typ runtimev1.Type_Code) (string, any, error) { | ||
| if val == nil { |
Member
There was a problem hiding this comment.
Just saw this PR and this is not needed for CH as its driver handles null values correctly, same for duckdb.
Member
There was a problem hiding this comment.
I did a brief test on CLI and seems to work with this also.
Member
There was a problem hiding this comment.
Hey @pjain1
So just below this line there is this check :
if typ == runtimev1.Type_CODE_DATE {
t, ok := val.(time.Time)
if !ok {
return "", nil, fmt.Errorf("could not cast value %v to time.Time for date type", val)
}
return "toDate(?)", t.Format(time.DateOnly), nil
}
For nil values it will return error: could not cast value nil....
Is there any issue with adding this check ? That will make the below condition safer.
Member
There was a problem hiding this comment.
OK got it, no issues with the check.
k-anshul
added a commit
that referenced
this pull request
May 1, 2026
* fix: emit NULL literal for nil values in `SelectInlineResults` BigQuery's Go client rejects nil parameter values in `bigquery.QueryParameter`. When a metrics aggregation query with comparison time ranges returns NULL dimension values, `getArgExpr` was emitting a `?` placeholder with a nil arg, causing "bigquery: nil parameter" errors. Emit a SQL `NULL` literal instead and skip appending nil to the args slice so positional parameter alignment is preserved. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * add tests * also add check in duckdb and clickhouse * more extensive test --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Anshul Khandelwal <12948312+k-anshul@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bigquery.QueryParameter.Valueacquisition_channelis NULL in some rows),getArgExprwas emitting a?placeholder with a nil argNULLliteral instead, and skips appending nil to the positional args sliceChecklist:
Developed in collaboration with Claude Code