calcite icon indicating copy to clipboard operation
calcite copied to clipboard

[CALCITE-5733] Simplify "a = ARRAY[1,2] AND a = ARRAY[2,3]" to "false"

Open YasuoStudyJava opened this issue 2 years ago • 15 comments

Simplification seem to not take into account that the specified field is of array type. In other words,it can simplify "a = 1 AND a = 2" to "false",but can not simplify “a = ARRAY[1,2] AND a = ARRAY[2,3]” to "false". This change can fix it. Linked to https://issues.apache.org/jira/browse/FLINK-32188, when submitting an SQL task with Flink to test a customized data source connector, I specified to query an array-type field of a temporary table with a fixed-value array. For example, "select * from image-source where URL=ARRAY ['/flink. jpg', '/flink_1. jpg'] AND URL=ARRAY ['/f. jpg', '/f_1. jpg']" can obtain two predicate conditions, this is illogical. Generally speaking, simplifying this SQL condition should not result in any predicates. Changes related to “RexSimplify.java” can fix it.

YasuoStudyJava avatar Jun 06 '23 08:06 YasuoStudyJava

Hi @YasuoStudyJava. The PR's headline should be formatted like "[CALCITE-5733] YOUR JIRA ISSUE SUMMARY", you can take a look at other PRs. Or the recently merged PR is also a good help to refer to.

ILuffZhe avatar Jun 09 '23 00:06 ILuffZhe

OK, I changed it, could you please take a look again to see if it is standardized.

YasuoStudyJava avatar Jun 09 '23 01:06 YasuoStudyJava

Can you also please add a unit test here? It helps reviewers to understand better.

ILuffZhe avatar Jun 09 '23 01:06 ILuffZhe

Can you also please add a unit test here? It helps reviewers to understand better.

I'll have a try to add a test.

YasuoStudyJava avatar Jun 09 '23 03:06 YasuoStudyJava

Can you also please add a unit test here? It helps reviewers to understand better.

I'll have a try to add a test.

BTW, I seem to not find pom.xml in source code of calcite? @ILuffZhe

YasuoStudyJava avatar Jun 09 '23 07:06 YasuoStudyJava

Can you also please add a unit test here? It helps reviewers to understand better.

I'll have a try to add a test.

BTW, I seem to not find pom.xml in source code of calcite? @ILuffZhe

We now use Gradle in Calcite, and you can find build.gradle.kts and gradle.properties in root dir. For more information, you can browse the website.

ILuffZhe avatar Jun 09 '23 07:06 ILuffZhe

@YasuoStudyJava we should also consider the case that the RexCall in projection, which the default RexUnknownAs is UNKNOWN, not the same as predicate in where clause.

herunkang2018 avatar Jun 27 '23 00:06 herunkang2018

Can you give an example?

YasuoStudyJava avatar Jun 30 '23 02:06 YasuoStudyJava

@YasuoStudyJava there are similar tests in RexProgramTest, and you could learn from that.

herunkang2018 avatar Jul 01 '23 04:07 herunkang2018

@YasuoStudyJava there are similar tests in RexProgramTest, and you could learn from that.

yeah,I know,but I met some problems when I pull the code and build in my IDEA. I am quite unfamiliar with ‘Gradle’, So code format correction and test cases have not started. Now the problem is:

Task :buildSrc:javacc:compileKotlin Could not load entry 89875aab070c1135c15229026edb1371 from remote build cache: Bucket 'calcite-gradle-cache' not found e: file:///E:/calcite/calcite/buildSrc/subprojects/javacc/src/main/kotlin/org/apache/calcite/buildtools/javacc/JavaCCTask.kt:66:13 Unresolved reference: main Task :buildSrc:javacc:compileKotlin FAILED

YasuoStudyJava avatar Jul 02 '23 15:07 YasuoStudyJava

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 90 days if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions.

github-actions[bot] avatar Dec 31 '24 03:12 github-actions[bot]

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 90 days if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions.

github-actions[bot] avatar Mar 21 '25 03:03 github-actions[bot]

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 90 days if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions.

github-actions[bot] avatar Jun 29 '25 03:06 github-actions[bot]

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 90 days if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions.

github-actions[bot] avatar Oct 27 '25 03:10 github-actions[bot]