Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(query): fix variant map access filter #6645

Merged
merged 1 commit into from
Jul 16, 2022

Conversation

b41sh
Copy link
Member

@b41sh b41sh commented Jul 15, 2022

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

Fix conflicting precedence of MapAccess and And, since the value of both of them is 20, we can't get the correct syntax tree when parsing the following SQL.

SELECT * FROM test WHERE id = 1 and labels:email = 'abc@test.com';

When performing data filtering, if the data types of the comparison are different, we will perform an implicit data type cast. For JSON values, some cast can't be successful, such as casting a string to a number or casting null to a string. Since the cast target type is not nullable, the following error will occur.

mysql> SELECT * FROM test WHERE labels:email = 'abc@test.com';
ERROR 1105 (HY000): Code: 1010, displayText = Cast error happens in casting from Variant to String (while in processor thread 0).

In order to solve this problem, we allow the cast target type to be nullable and mark the null value rows as deleted after the comparison operation.

Fixes #6590

@vercel
Copy link

vercel bot commented Jul 15, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
databend ⬜️ Ignored (Inspect) Jul 15, 2022 at 10:11AM (UTC)

@mergify mergify bot added the pr-bugfix this PR patches a bug in codebase label Jul 15, 2022
@b41sh b41sh force-pushed the fix-map-access-filter branch 2 times, most recently from 714c8f4 to d201746 Compare July 15, 2022 09:46
@b41sh b41sh marked this pull request as ready for review July 15, 2022 10:45
@b41sh b41sh requested a review from sundy-li July 15, 2022 10:46
@sundy-li sundy-li merged commit 00e6803 into databendlabs:main Jul 16, 2022
@BohuTANG
Copy link
Member

We can add more documents about the variant map with this patch @soyeric128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-bugfix this PR patches a bug in codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Use object data types in select where
3 participants