Postgres Query Parser Bugfixes #253
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
This PR fixes critical bugs in Postgres path.
1. Unquoted PG Col Names Containing Hyphens
We were not quoting PG col names if it was a JSON array (bug). Due to this, these fields were being referred to as
p1(customAttribute_dot_dev-ops-owner)for example. PG throws an unknown character exception for this. The correct way to do this is to quote the col name asp1("customAttribute_dot_dev-ops-owner").2. PreparedStatement Misinterpreting the ? Operator
For JSONB scalar fields, we were using the
parent ? childexpr.?is the contains operator. But prepared statement incorrectly interprets it as a placeholder and fills in a value. For now, I have reverted it to usingIS NULL/IS NOT NULL.3. Handle Unnest + EXISTS/NOT_EXISTS on Native/JSONB Arrays Correctly
For queries like:
In which we unnest an array and then apply a filter
EMPTY/IS_NOT_EMPTYon the array col, the parser was generating an incorrect query. This has been fixed (please see the UTs for the correct behaviour).4. Handle Unnest + IN/NOT_IN on Native/JSONB Arrays Correctly
This is similar to the previous case, for queries in which we first unnest an array col, and then apply a filter on it.
5. Handle CONTAINS/NOT_CONTAINS on Top Level Array Fields
This wasn't working till now.
Testing
Checklist: