You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by ch...@apache.org on 2020/06/18 08:20:26 UTC
[calcite] branch master updated: [CALCITE-4060] Supports implicit
type coercion for "NOT IN".
This is an automated email from the ASF dual-hosted git repository.
chunwei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push:
new 72f3322 [CALCITE-4060] Supports implicit type coercion for "NOT IN".
72f3322 is described below
commit 72f3322b9845b59eff4435282dbb2fd3a741ac68
Author: Jiatao Tao <24...@qq.com>
AuthorDate: Thu Jun 11 21:47:42 2020 +0800
[CALCITE-4060] Supports implicit type coercion for "NOT IN".
---
.../calcite/sql/validate/implicit/TypeCoercionImpl.java | 2 +-
.../apache/calcite/test/TypeCoercionConverterTest.java | 8 ++++++++
.../apache/calcite/test/TypeCoercionConverterTest.xml | 17 ++++++++++++++++-
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.java b/core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.java
index 5b846e9..e122152 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.java
@@ -449,7 +449,7 @@ public class TypeCoercionImpl extends AbstractTypeCoercion {
*/
public boolean inOperationCoercion(SqlCallBinding binding) {
SqlOperator operator = binding.getOperator();
- if (operator.getKind() == SqlKind.IN) {
+ if (operator.getKind() == SqlKind.IN || operator.getKind() == SqlKind.NOT_IN) {
assert binding.getOperandCount() == 2;
final RelDataType type1 = binding.getOperandType(0);
final RelDataType type2 = binding.getOperandType(1);
diff --git a/core/src/test/java/org/apache/calcite/test/TypeCoercionConverterTest.java b/core/src/test/java/org/apache/calcite/test/TypeCoercionConverterTest.java
index 029f44f..afbbe79 100644
--- a/core/src/test/java/org/apache/calcite/test/TypeCoercionConverterTest.java
+++ b/core/src/test/java/org/apache/calcite/test/TypeCoercionConverterTest.java
@@ -61,6 +61,14 @@ class TypeCoercionConverterTest extends SqlToRelTestBase {
+ "from (values (true, true, true))");
}
+ @Test void testNotInOperation() {
+ checkPlanEquals("select\n"
+ + "1 not in ('1', '2', '3') as f0,\n"
+ + "(1, 2) not in (('1', '2')) as f1,\n"
+ + "(1, 2) not in (('1', '2'), ('3', '4')) as f2\n"
+ + "from (values (false, false, false))");
+ }
+
/** Test cases for {@link TypeCoercion#inOperationCoercion}. */
@Test void testInDateTimestamp() {
checkPlanEquals("select (t1_timestamp, t1_date)\n"
diff --git a/core/src/test/resources/org/apache/calcite/test/TypeCoercionConverterTest.xml b/core/src/test/resources/org/apache/calcite/test/TypeCoercionConverterTest.xml
index d4d3585..771c740 100644
--- a/core/src/test/resources/org/apache/calcite/test/TypeCoercionConverterTest.xml
+++ b/core/src/test/resources/org/apache/calcite/test/TypeCoercionConverterTest.xml
@@ -31,7 +31,22 @@ LogicalProject(F0=[true], F1=[true], F2=[true])
]]>
</Resource>
</TestCase>
- <TestCase name="testInDateTimestamp">
+ <TestCase name="testNotInOperation">
+ <Resource name="sql">
+ <![CDATA[select
+1 not in ('1', '2', '3') as f0,
+(1, 2) not in (('1', '2')) as f1,
+(1, 2) not in (('1', '2'), ('3', '4')) as f2
+from (values (false, false, false))]]>
+ </Resource>
+ <Resource name="plan">
+ <![CDATA[
+LogicalProject(F0=[false], F1=[false], F2=[false])
+ LogicalValues(tuples=[[{ false, false, false }]])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testInDateTimestamp">
<Resource name="sql">
<![CDATA[select (t1_timestamp, t1_date)
in ((DATE '2020-04-16', TIMESTAMP '2020-04-16 11:40:53'))