fix sql results mixed array and scalar values #16105
Merged
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.
Description
Fixes an issue which can occur when using schema discovery on columns with a mix of array and scalar values and querying with scan queries, where SQL result coercion does not expect scalar values to be present and so fails the results. This issue does not occur when grouping, since that homogenizes the results to the least restrictive type.
An easy way to repro this is to use the 'kttm' nested example data with full schema discovery, where the language column has a mix of scalar and array values, and then
select *
style query. The error would occur in broker error logs like:and present in the web-console something like this:
which.. is not a great error message for this scenario I suppose, but is indeed what happens when we explode while coercing results on the fly like this. I'm unsure what a better way to handle this case would be, since it isn't really something the user can retry we might want to figure out a better way to handle this, but maybe out of scope of this PR since we are returning a 200 response code and just happen to fail midway through returning them.
This PR doesn't change any behaviors, it just modifies things to be more permissive and allows some queries with mixed array schemas to succeed now where they previously might have failed by wrapping the scalar values into a single element array (which is consistent with the native layer behavior and why none of the other query types have this issue).
This PR has: