You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "snuyanzin (via GitHub)" <gi...@apache.org> on 2023/05/09 20:43:49 UTC

[GitHub] [flink] snuyanzin opened a new pull request, #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

snuyanzin opened a new pull request, #22558:
URL: https://github.com/apache/flink/pull/22558

   ## What is the purpose of the change
   
   Upgrade Calcite to 1.31.0
   
   TBD
   
   
   ## Verifying this change
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`:9no)
     - The serializers: (no)
     - The runtime per-record code paths (performance sensitive): (no )
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no )
     - The S3 file system connector: (no )
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (no)
     - If yes, how is the feature documented? (not applicable )
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on PR #22558:
URL: https://github.com/apache/flink/pull/22558#issuecomment-1610043104

   @flinkbot run azure


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1237090987


##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/stream/table/CalcTest.xml:
##########
@@ -107,14 +107,14 @@ Calc(select=[*org.apache.flink.table.planner.expressions.utils.Func24$$2da7dcb3c
   <TestCase name="testNotIn">
     <Resource name="ast">
       <![CDATA[
-LogicalFilter(condition=[OR(SEARCH($1, Sarg[(-∞..1), (1..2), (2..3), (3..4), (4..5), (5..6), (6..7), (7..8), (8..9), (9..10), (10..11), (11..12), (12..13), (13..14), (14..15), (15..16), (16..17), (17..18), (18..19), (19..20), (20..21), (21..22), (22..23), (23..24), (24..25), (25..26), (26..27), (27..28), (28..29), (29..30), (30..+∞)]), SEARCH($2, Sarg[(-∞.._UTF-16LE'xx'), (_UTF-16LE'xx'..+∞)]:CHAR(2) CHARACTER SET "UTF-16LE"))])
+LogicalFilter(condition=[OR(SEARCH($1, Sarg[(-∞..1), (1..2), (2..3), (3..4), (4..5), (5..6), (6..7), (7..8), (8..9), (9..10), (10..11), (11..12), (12..13), (13..14), (14..15), (15..16), (16..17), (17..18), (18..19), (19..20), (20..21), (21..22), (22..23), (23..24), (24..25), (25..26), (26..27), (27..28), (28..29), (29..30), (30..+∞)]), <>($2, _UTF-16LE'xx'))])

Review Comment:
   oops, my bad... in fact it was done one commit before CALCITE-5134
   with this one https://github.com/apache/calcite/commit/e64a21ee27600537e0498cd1f72475ad1a1a0d2b
   under this JIRA issue https://issues.apache.org/jira/browse/CALCITE-5169



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1190405680


##########
flink-table/flink-sql-parser/src/main/codegen/includes/parserImpls.ftl:
##########
@@ -1335,12 +1335,14 @@ SqlNode RichSqlInsert() :
     final SqlNodeList keywordList;
     final List<SqlLiteral> extendedKeywords = new ArrayList<SqlLiteral>();
     final SqlNodeList extendedKeywordList;
-    SqlNode table;
-    SqlNodeList extendList = null;
+    final SqlIdentifier tableName;
+    SqlNode tableRef;
+    final SqlNodeList extendList;

Review Comment:
   Changes in this file are a consequence  of refactor of parser https://github.com/apache/calcite/commit/515f3356a6a1ab4bd570c1c20bec9a7e5d4aca5f



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1244364545


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java:
##########
@@ -469,10 +469,10 @@ private static List<TestSetSpec> allTypesBasic() {
                         .fromCase(BIGINT(), DEFAULT_NEGATIVE_BIGINT, 539222987)
                         .fromCase(FLOAT(), DEFAULT_POSITIVE_FLOAT, 123)
                         .fromCase(FLOAT(), DEFAULT_NEGATIVE_FLOAT, -123)
-                        .fromCase(FLOAT(), 9234567891.12, 644633299)
+                        .fromCase(FLOAT(), 9234567891.12, 2147483647)

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1239034473


##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/DagOptimizationTest.xml:
##########
@@ -379,30 +382,30 @@ LogicalLegacySink(name=[`default_catalog`.`default_database`.`retractSink2`], fi
       <![CDATA[
 LegacySink(name=[`default_catalog`.`default_database`.`retractSink1`], fields=[a, total_c], changelogMode=[NONE])
 +- Union(all=[true], union=[a, total_c], changelogMode=[I,UB,UA])
-   :- Calc(select=[a, total_c], where=[>(a, 50)], changelogMode=[I,UB,UA])
-   :  +- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
-   :     +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT c) AS total_c], changelogMode=[I,UB,UA])
-   :        +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
-   :           +- Calc(select=[a, b, f0 AS c], changelogMode=[I])
-   :              +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
-   :                 +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[AND(>=(b, UNIX_TIMESTAMP('${startTime}')), <>(c, ''))], changelogMode=[I])
+   :- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
+   :  +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT f0) AS total_c], changelogMode=[I,UB,UA])
+   :     +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
+   :        +- Calc(select=[a, b, f0], where=[>(a, 50)], changelogMode=[I])
+   :           +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
+   :              +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[<>(c, '')], changelogMode=[I])
+   :                 +- Calc(select=[a, b, c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])
    :                    +- LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c], changelogMode=[I])
-   +- Calc(select=[a, CAST(total_c AS BIGINT) AS total_c], where=[>(a, 50)], changelogMode=[I])
-      +- Calc(select=[a, 0 AS total_c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])
+   +- Calc(select=[a, 0 AS total_c], where=[>(a, 50)], changelogMode=[I])
+      +- Calc(select=[a, b, c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])
          +- LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c], changelogMode=[I])
 
 LegacySink(name=[`default_catalog`.`default_database`.`retractSink2`], fields=[a, total_c], changelogMode=[NONE])
 +- Union(all=[true], union=[a, total_c], changelogMode=[I,UB,UA])
-   :- Calc(select=[a, total_c], where=[<(a, 50)], changelogMode=[I,UB,UA])
-   :  +- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
-   :     +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT c) AS total_c], changelogMode=[I,UB,UA])
-   :        +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
-   :           +- Calc(select=[a, b, f0 AS c], changelogMode=[I])
-   :              +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
-   :                 +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[AND(>=(b, UNIX_TIMESTAMP('${startTime}')), <>(c, ''))], changelogMode=[I])
+   :- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
+   :  +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT f0) AS total_c], changelogMode=[I,UB,UA])
+   :     +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
+   :        +- Calc(select=[a, b, f0], where=[<(a, 50)], changelogMode=[I])
+   :           +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
+   :              +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[<>(c, '')], changelogMode=[I])
+   :                 +- Calc(select=[a, b, c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])
    :                    +- LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c], changelogMode=[I])
-   +- Calc(select=[a, CAST(total_c AS BIGINT) AS total_c], where=[<(a, 50)], changelogMode=[I])
-      +- Calc(select=[a, 0 AS total_c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])
+   +- Calc(select=[a, 0 AS total_c], where=[<(a, 50)], changelogMode=[I])
+      +- Calc(select=[a, b, c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])

Review Comment:
   After `AddJsonTypeOperatorEnabled` set to `false` no changes in this file are required, so this file was reverted



##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/batch/sql/DagOptimizationTest.xml:
##########
@@ -478,33 +483,37 @@ LogicalLegacySink(name=[`default_catalog`.`default_database`.`sink3`], fields=[t
     </Resource>
     <Resource name="optimized exec plan">
       <![CDATA[
-Union(all=[true], union=[a, c])(reuse_id=[1])
-:- Calc(select=[a, c])
-:  +- LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c])
-+- Calc(select=[d, f])
-   +- LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable1, source: [TestTableSource(d, e, f)]]], fields=[d, e, f])
+LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c])(reuse_id=[1])
+
+LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable1, source: [TestTableSource(d, e, f)]]], fields=[d, e, f])(reuse_id=[2])
 
 LegacySink(name=[`default_catalog`.`default_database`.`sink1`], fields=[a, c])
-+- Reused(reference_id=[1])
++- Union(all=[true], union=[a, c])
+   :- Calc(select=[a, c])
+   :  +- Reused(reference_id=[1])
+   +- Calc(select=[d, f])

Review Comment:
   After `AddJsonTypeOperatorEnabled` set to `false` no changes in this file are required, so this file was reverted



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1239069716


##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/rules/logical/subquery/SubqueryCorrelateVariablesValidationTest.scala:
##########
@@ -96,7 +96,7 @@ class SubqueryCorrelateVariablesValidationTest extends SubQueryTestBase {
     util.verifyRelPlan(sqlQuery)
   }
 
-  @Test(expected = classOf[TableException])
+  @Test

Review Comment:
   ```
   [ERROR] org.apache.flink.table.planner.plan.rules.logical.subquery.SubqueryCorrelateVariablesValidationTest.testWithFilterJoinCorrelate  Time elapsed: 0.036 s  <<< ERROR!
   org.apache.flink.table.api.TableException: unexpected correlate variable $cor0 in the plan
   	at org.apache.flink.table.planner.plan.optimize.program.FlinkDecorrelateProgram.checkCorrelVariableExists(FlinkDecorrelateProgram.scala:59)
   	at org.apache.flink.table.planner.plan.optimize.program.FlinkDecorrelateProgram.optimize(FlinkDecorrelateProgram.scala:42)
   	at org.apache.flink.table.planner.plan.optimize.program.FlinkChainedProgram.$anonfun$optimize$1(FlinkChainedProgram.scala:59)
   	at scala.collection.TraversableOnce.$anonfun$foldLeft$1(TraversableOnce.scala:156)
   	at scala.collection.TraversableOnce.$anonfun$foldLeft$1$adapted(TraversableOnce.scala:156)
   	at scala.collection.Iterator.foreach(Iterator.scala:937)
   	at scala.collection.Iterator.foreach$(Iterator.scala:937)
   	at scala.collection.AbstractIterator.foreach(Iterator.scala:1425)
   	at scala.collection.IterableLike.foreach(IterableLike.scala:70)
   	at scala.collection.IterableLike.foreach$(IterableLike.scala:69)
   	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
   	at scala.collection.TraversableOnce.foldLeft(TraversableOnce.scala:156)
   	at scala.collection.TraversableOnce.foldLeft$(TraversableOnce.scala:154)
   	at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104)
   	at org.apache.flink.table.planner.plan.optimize.program.FlinkChainedProgram.optimize(FlinkChainedProgram.scala:55)
   	at org.apache.flink.table.planner.plan.optimize.BatchCommonSubGraphBasedOptimizer.optimizeTree(BatchCommonSubGraphBasedOptimizer.scala:93)
   	at org.apache.flink.table.planner.plan.optimize.BatchCommonSubGraphBasedOptimizer.optimizeBlock(BatchCommonSubGraphBasedOptimizer.scala:58)
   	at org.apache.flink.table.planner.plan.optimize.BatchCommonSubGraphBasedOptimizer.$anonfun$doOptimize$1(BatchCommonSubGraphBasedOptimizer.scala:45)
   	at org.apache.flink.table.planner.plan.optimize.BatchCommonSubGraphBasedOptimizer.$anonfun$doOptimize$1$adapted(BatchCommonSubGraphBasedOptimizer.scala:45)
   	at scala.collection.immutable.List.foreach(List.scala:388)
   ...
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1190409133


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java:
##########
@@ -526,7 +526,7 @@ private static List<TestSetSpec> allTypesBasic() {
                         .fromCase(BIGINT(), DEFAULT_NEGATIVE_BIGINT, DEFAULT_NEGATIVE_BIGINT)
                         .fromCase(FLOAT(), DEFAULT_POSITIVE_FLOAT, 123L)
                         .fromCase(FLOAT(), DEFAULT_NEGATIVE_FLOAT, -123L)
-                        .fromCase(FLOAT(), 9234567891.12, 9234567891L)
+                        .fromCase(FLOAT(), 9234567891.12, 9234568192L)

Review Comment:
   This looks a bit weird however after checking it the result is same as for
   ```java
   Float.parseFloat("9234567891.12");
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] twalthr closed pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr closed pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0
URL: https://github.com/apache/flink/pull/22558


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1242916945


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java:
##########
@@ -1132,22 +1132,14 @@ private static List<TestSetSpec> numericBounds() {
                         .fromCase(DOUBLE(), -1.7976931348623157E308d, Float.NEGATIVE_INFINITY)
                         .build(),
                 CastTestSpecBuilder.testCastTo(DECIMAL(38, 0))
-                        .fromCase(TINYINT(), Byte.MIN_VALUE - 1, new BigDecimal(Byte.MIN_VALUE - 1))
-                        .fromCase(TINYINT(), Byte.MAX_VALUE + 1, new BigDecimal(Byte.MAX_VALUE + 1))
-                        .fromCase(
-                                SMALLINT(),
-                                Short.MIN_VALUE - 1,
-                                new BigDecimal(Short.MIN_VALUE - 1))
-                        .fromCase(
-                                SMALLINT(),
-                                Short.MAX_VALUE + 1,
-                                new BigDecimal(Short.MAX_VALUE + 1))
-                        .fromCase(
-                                INT(), Integer.MIN_VALUE - 1, new BigDecimal(Integer.MIN_VALUE - 1))
-                        .fromCase(
-                                INT(), Integer.MAX_VALUE + 1, new BigDecimal(Integer.MAX_VALUE + 1))
-                        .fromCase(BIGINT(), Long.MIN_VALUE - 1, new BigDecimal(Long.MIN_VALUE - 1))
-                        .fromCase(BIGINT(), Long.MAX_VALUE + 1, new BigDecimal(Long.MAX_VALUE + 1))
+                        .fromCase(TINYINT(), Byte.MIN_VALUE - 1, new BigDecimal(Byte.MAX_VALUE))

Review Comment:
   May be I didn't get what you mean... I added cast for input however here expected type is `BigDecimal` since here it is cast to `DECIMAL(38, 0)`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1239034473


##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/DagOptimizationTest.xml:
##########
@@ -379,30 +382,30 @@ LogicalLegacySink(name=[`default_catalog`.`default_database`.`retractSink2`], fi
       <![CDATA[
 LegacySink(name=[`default_catalog`.`default_database`.`retractSink1`], fields=[a, total_c], changelogMode=[NONE])
 +- Union(all=[true], union=[a, total_c], changelogMode=[I,UB,UA])
-   :- Calc(select=[a, total_c], where=[>(a, 50)], changelogMode=[I,UB,UA])
-   :  +- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
-   :     +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT c) AS total_c], changelogMode=[I,UB,UA])
-   :        +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
-   :           +- Calc(select=[a, b, f0 AS c], changelogMode=[I])
-   :              +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
-   :                 +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[AND(>=(b, UNIX_TIMESTAMP('${startTime}')), <>(c, ''))], changelogMode=[I])
+   :- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
+   :  +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT f0) AS total_c], changelogMode=[I,UB,UA])
+   :     +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
+   :        +- Calc(select=[a, b, f0], where=[>(a, 50)], changelogMode=[I])
+   :           +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
+   :              +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[<>(c, '')], changelogMode=[I])
+   :                 +- Calc(select=[a, b, c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])
    :                    +- LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c], changelogMode=[I])
-   +- Calc(select=[a, CAST(total_c AS BIGINT) AS total_c], where=[>(a, 50)], changelogMode=[I])
-      +- Calc(select=[a, 0 AS total_c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])
+   +- Calc(select=[a, 0 AS total_c], where=[>(a, 50)], changelogMode=[I])
+      +- Calc(select=[a, b, c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])
          +- LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c], changelogMode=[I])
 
 LegacySink(name=[`default_catalog`.`default_database`.`retractSink2`], fields=[a, total_c], changelogMode=[NONE])
 +- Union(all=[true], union=[a, total_c], changelogMode=[I,UB,UA])
-   :- Calc(select=[a, total_c], where=[<(a, 50)], changelogMode=[I,UB,UA])
-   :  +- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
-   :     +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT c) AS total_c], changelogMode=[I,UB,UA])
-   :        +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
-   :           +- Calc(select=[a, b, f0 AS c], changelogMode=[I])
-   :              +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
-   :                 +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[AND(>=(b, UNIX_TIMESTAMP('${startTime}')), <>(c, ''))], changelogMode=[I])
+   :- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
+   :  +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT f0) AS total_c], changelogMode=[I,UB,UA])
+   :     +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
+   :        +- Calc(select=[a, b, f0], where=[<(a, 50)], changelogMode=[I])
+   :           +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
+   :              +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[<>(c, '')], changelogMode=[I])
+   :                 +- Calc(select=[a, b, c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])
    :                    +- LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c], changelogMode=[I])
-   +- Calc(select=[a, CAST(total_c AS BIGINT) AS total_c], where=[<(a, 50)], changelogMode=[I])
-      +- Calc(select=[a, 0 AS total_c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])
+   +- Calc(select=[a, 0 AS total_c], where=[<(a, 50)], changelogMode=[I])
+      +- Calc(select=[a, b, c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])

Review Comment:
   After `AddJsonTypeOperatorEnabled` no changes in this file are required, so this file was reverted



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] melin commented on pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "melin (via GitHub)" <gi...@apache.org>.
melin commented on PR #22558:
URL: https://github.com/apache/flink/pull/22558#issuecomment-1541872159

   Can I upgrade to 1.34.0?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1190406330


##########
flink-table/flink-table-planner/pom.xml:
##########
@@ -99,16 +99,10 @@ under the License.
 				</exclusion>
 			</exclusions>
 		</dependency>
-		<!-- Use newer version v1.1.2 as in Calcite because org.junit.jupiter:junit-jupiter contains it -->
-		<dependency>
-			<artifactId>apiguardian-api</artifactId>
-			<groupId>org.apiguardian</groupId>
-			<version>1.1.2</version>
-		</dependency>

Review Comment:
   As mentioned above Calcite 1.31.0 now depends on 1.1.2 api.guardian (same as junit-jupiter) 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] twalthr commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1243287053


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java:
##########
@@ -526,7 +526,7 @@ private static List<TestSetSpec> allTypesBasic() {
                         .fromCase(BIGINT(), DEFAULT_NEGATIVE_BIGINT, DEFAULT_NEGATIVE_BIGINT)
                         .fromCase(FLOAT(), DEFAULT_POSITIVE_FLOAT, 123L)
                         .fromCase(FLOAT(), DEFAULT_NEGATIVE_FLOAT, -123L)
-                        .fromCase(FLOAT(), 9234567891.12, 9234567891L)
+                        .fromCase(FLOAT(), 9234567891.12, (long) 9234567891.12f)

Review Comment:
   Same here, should be:
   
   ```
   .fromCase(FLOAT(), 9234567891.12f, (long) 9234567891.12f)
   ```



##########
flink-table/flink-sql-jdbc-driver/pom.xml:
##########
@@ -84,6 +84,12 @@
 			<version>${project.version}</version>
 			<scope>test</scope>
 		</dependency>
+		<dependency>
+			<groupId>com.google.guava</groupId>
+			<artifactId>guava</artifactId>
+			<version>${guava.version}</version>
+			<scope>provided</scope>
+		</dependency>

Review Comment:
   But why is `flink-sql-jdbc-driver` is affected here? We should change the pom.xml of the `flink-sql-parser`? It seems `flink-sql-jdbc-driver` is just a symptom, not the root cause.



##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java:
##########
@@ -469,10 +469,10 @@ private static List<TestSetSpec> allTypesBasic() {
                         .fromCase(BIGINT(), DEFAULT_NEGATIVE_BIGINT, 539222987)
                         .fromCase(FLOAT(), DEFAULT_POSITIVE_FLOAT, 123)
                         .fromCase(FLOAT(), DEFAULT_NEGATIVE_FLOAT, -123)
-                        .fromCase(FLOAT(), 9234567891.12, 644633299)
+                        .fromCase(FLOAT(), 9234567891.12, 2147483647)

Review Comment:
   This line is still not correct. It says:
   ```
   .fromCase(FLOAT(), 9234567891.12, 2147483647)
   ```
   
   But the argument is not float. It should be:
   ```
   .fromCase(FLOAT(), 9234567891.12f, 2147483647)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1244366543


##########
flink-table/flink-sql-jdbc-driver/pom.xml:
##########
@@ -84,6 +84,12 @@
 			<version>${project.version}</version>
 			<scope>test</scope>
 		</dependency>
+		<dependency>
+			<groupId>com.google.guava</groupId>
+			<artifactId>guava</artifactId>
+			<version>${guava.version}</version>
+			<scope>provided</scope>
+		</dependency>

Review Comment:
   looks like 100% will not work since sql client explicitely depends on commons-io, so this one is currently skipped,
   all others are applied.
   May be it makes sense to remove commons-io dep (only one method) within a follow up task



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1239034289


##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/DagOptimizationTest.xml:
##########
@@ -379,30 +382,30 @@ LogicalLegacySink(name=[`default_catalog`.`default_database`.`retractSink2`], fi
       <![CDATA[
 LegacySink(name=[`default_catalog`.`default_database`.`retractSink1`], fields=[a, total_c], changelogMode=[NONE])
 +- Union(all=[true], union=[a, total_c], changelogMode=[I,UB,UA])
-   :- Calc(select=[a, total_c], where=[>(a, 50)], changelogMode=[I,UB,UA])
-   :  +- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
-   :     +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT c) AS total_c], changelogMode=[I,UB,UA])
-   :        +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
-   :           +- Calc(select=[a, b, f0 AS c], changelogMode=[I])
-   :              +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
-   :                 +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[AND(>=(b, UNIX_TIMESTAMP('${startTime}')), <>(c, ''))], changelogMode=[I])
+   :- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
+   :  +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT f0) AS total_c], changelogMode=[I,UB,UA])
+   :     +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
+   :        +- Calc(select=[a, b, f0], where=[>(a, 50)], changelogMode=[I])
+   :           +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
+   :              +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[<>(c, '')], changelogMode=[I])
+   :                 +- Calc(select=[a, b, c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])

Review Comment:
   After `AddJsonTypeOperatorEnabled` set to `false` no changes in this file are required, so this file was reverted



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1244366543


##########
flink-table/flink-sql-jdbc-driver/pom.xml:
##########
@@ -84,6 +84,12 @@
 			<version>${project.version}</version>
 			<scope>test</scope>
 		</dependency>
+		<dependency>
+			<groupId>com.google.guava</groupId>
+			<artifactId>guava</artifactId>
+			<version>${guava.version}</version>
+			<scope>provided</scope>
+		</dependency>

Review Comment:
   looks like 100% will not work since sql client explicitely depends on commons-iowhich leads to failure of some e2e tests e.g. [1], so this one is currently skipped,
   all others are applied.
   May be it makes sense to remove commons-io dep (only one method) within a follow up task
   
   [1] https://dev.azure.com/apache-flink/apache-flink/_build/results?buildId=50516&view=logs&j=af184cdd-c6d8-5084-0b69-7e9c67b35f7a&t=0f3adb59-eefa-51c6-2858-3654d9e0749d&l=4398



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1243930582


##########
flink-table/flink-sql-jdbc-driver/pom.xml:
##########
@@ -84,6 +84,12 @@
 			<version>${project.version}</version>
 			<scope>test</scope>
 		</dependency>
+		<dependency>
+			<groupId>com.google.guava</groupId>
+			<artifactId>guava</artifactId>
+			<version>${guava.version}</version>
+			<scope>provided</scope>
+		</dependency>

Review Comment:
   yeah, probably you are right
   It seems I was able to find the root cause
   https://github.com/apache/flink/pull/20931/files#diff-0afcdb67ea32dadfd26f5987cc2ad4b12015cef9481fd05f9129b0eed2e35f61R547-R557
   
   where there is no relocation
   In fact only one is enough for current issue
   ```xml
   <relocation>
   	<pattern>com.google</pattern>
   	<shadedPattern>org.apache.flink.calcite.shaded.com.google</shadedPattern>
   </relocation>
   ```
   however i think it's better to keep it in sync with table-planner



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1242932736


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java:
##########
@@ -469,10 +469,10 @@ private static List<TestSetSpec> allTypesBasic() {
                         .fromCase(BIGINT(), DEFAULT_NEGATIVE_BIGINT, 539222987)
                         .fromCase(FLOAT(), DEFAULT_POSITIVE_FLOAT, 123)
                         .fromCase(FLOAT(), DEFAULT_NEGATIVE_FLOAT, -123)
-                        .fromCase(FLOAT(), 9234567891.12, 644633299)
+                        .fromCase(FLOAT(), 9234567891.12, 2147483647)

Review Comment:
   Added release notes to the JIRA issue



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1190401612


##########
flink-table/flink-sql-parser/pom.xml:
##########
@@ -162,11 +163,6 @@ under the License.
 					<groupId>com.google.uzaygezen</groupId>
 					<artifactId>uzaygezen-core</artifactId>
 				</exclusion>
-				<!-- Excluding org.apiguardian:apiguardian-api v1.1.0 because org.junit.jupiter:junit-jupiter contains newer version v1.1.2 -->
-				<exclusion>
-					<groupId>org.apiguardian</groupId>
-					<artifactId>apiguardian-api</artifactId>
-				</exclusion>

Review Comment:
   Calcite 1.31.0 now depends on 1.1.2 api.guardian (same as junit-jupiter) and since the latest commit to api.guardian was about 2 years ago[1] it's pretty unlikely there will be new versions...
   
   [1] https://github.com/apiguardian-team/apiguardian



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on PR #22558:
URL: https://github.com/apache/flink/pull/22558#issuecomment-1549165123

   rebased to resolve conflicts


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] flinkbot commented on pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #22558:
URL: https://github.com/apache/flink/pull/22558#issuecomment-1540875174

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "69b4b22e38f67abe10d98d7069435855fa3b0dc3",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "69b4b22e38f67abe10d98d7069435855fa3b0dc3",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 69b4b22e38f67abe10d98d7069435855fa3b0dc3 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1233372251


##########
flink-table/flink-sql-jdbc-driver/pom.xml:
##########
@@ -84,6 +84,12 @@
 			<version>${project.version}</version>
 			<scope>test</scope>
 		</dependency>
+		<dependency>
+			<groupId>com.google.guava</groupId>
+			<artifactId>guava</artifactId>
+			<version>${guava.version}</version>
+			<scope>provided</scope>
+		</dependency>

Review Comment:
   yes, sort of.
   After closer look I realized that before 1.31.0 `FlinkSqlParserImpl` didn't depend on guava. And with 1.31.0 after these 2 commits
   https://github.com/apache/calcite/commit/7c1e2746b94a50f0bb08571287acb5327fdc1b16
   https://github.com/apache/calcite/commit/75d064f659a038371d84f9fdba7847e1631d1f1d
   it starts depending on guava and as a result starts requiring same dependency as for tests 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on PR #22558:
URL: https://github.com/apache/flink/pull/22558#issuecomment-1603319716

   Sorry for the delay
   it took a bit longer to find out the root cause.
   
   :see_no_evil: seems the reason was that between announcement of 1.31.0 commit and preparing for the next iteration there was another one https://github.com/apache/calcite/commit/8844146182c4220c0747e46dcfb745288df7e39c ([[CALCITE-4989](https://issues.apache.org/jira/browse/CALCITE-4989)] Nested JSON_OBJECT creation does not produce proper json). It introduces a new property `AddJsonTypeOperatorEnabled` and makes it `true` by default... Depending property value it makes some extra query rewrites... As experiment shown it impacts `DagOptimization`. Setting property to `false` (Calcite 1.30.0 behavior)  solves the issue and no changes at `DagOptimization` are required.
   
   Sorry, I should have realized it earlier
   
   Also rebased PRs since libssl version bumped and old version started to be a reason of failures.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1239034289


##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/DagOptimizationTest.xml:
##########
@@ -379,30 +382,30 @@ LogicalLegacySink(name=[`default_catalog`.`default_database`.`retractSink2`], fi
       <![CDATA[
 LegacySink(name=[`default_catalog`.`default_database`.`retractSink1`], fields=[a, total_c], changelogMode=[NONE])
 +- Union(all=[true], union=[a, total_c], changelogMode=[I,UB,UA])
-   :- Calc(select=[a, total_c], where=[>(a, 50)], changelogMode=[I,UB,UA])
-   :  +- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
-   :     +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT c) AS total_c], changelogMode=[I,UB,UA])
-   :        +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
-   :           +- Calc(select=[a, b, f0 AS c], changelogMode=[I])
-   :              +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
-   :                 +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[AND(>=(b, UNIX_TIMESTAMP('${startTime}')), <>(c, ''))], changelogMode=[I])
+   :- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
+   :  +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT f0) AS total_c], changelogMode=[I,UB,UA])
+   :     +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
+   :        +- Calc(select=[a, b, f0], where=[>(a, 50)], changelogMode=[I])
+   :           +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
+   :              +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[<>(c, '')], changelogMode=[I])
+   :                 +- Calc(select=[a, b, c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])

Review Comment:
   After `AddJsonTypeOperatorEnabled` no changes in this file are required, so this file was reverted



##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/batch/sql/DagOptimizationTest.xml:
##########
@@ -478,33 +483,37 @@ LogicalLegacySink(name=[`default_catalog`.`default_database`.`sink3`], fields=[t
     </Resource>
     <Resource name="optimized exec plan">
       <![CDATA[
-Union(all=[true], union=[a, c])(reuse_id=[1])
-:- Calc(select=[a, c])
-:  +- LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c])
-+- Calc(select=[d, f])
-   +- LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable1, source: [TestTableSource(d, e, f)]]], fields=[d, e, f])
+LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c])(reuse_id=[1])
+
+LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable1, source: [TestTableSource(d, e, f)]]], fields=[d, e, f])(reuse_id=[2])
 
 LegacySink(name=[`default_catalog`.`default_database`.`sink1`], fields=[a, c])
-+- Reused(reference_id=[1])
++- Union(all=[true], union=[a, c])
+   :- Calc(select=[a, c])
+   :  +- Reused(reference_id=[1])
+   +- Calc(select=[d, f])

Review Comment:
   After `AddJsonTypeOperatorEnabled` no changes in this file are required, so this file was reverted



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1239021813


##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/rules/logical/subquery/SubqueryCorrelateVariablesValidationTest.xml:
##########
@@ -99,4 +99,34 @@ LogicalProject(min_t3d=[$9], max_t2h=[$11])
 ]]>
     </Resource>
   </TestCase>
+  <TestCase name="testWithFilterJoinCorrelate">
+	<Resource name="sql">
+			<![CDATA[
+SELECT t1a
+FROM   t1
+WHERE  EXISTS (SELECT max(t2h) FROM t2
+               LEFT OUTER JOIN t1 ttt
+               ON t2.t2a=t1.t1a)
+      ]]>
+	</Resource>
+	<Resource name="ast">
+			<![CDATA[
+LogicalProject(t1a=[$0])
++- LogicalFilter(condition=[EXISTS({
+LogicalAggregate(group=[{}], EXPR$0=[MAX($0)])
+  LogicalProject(t2h=[$7])
+    LogicalJoin(condition=[=($0, $cor0.t1a)], joinType=[left])
+      LogicalTableScan(table=[[default_catalog, default_database, t2, source: [TestTableSource(t2a, t2b, t2c, t2d, t2e, t2f, t2g, t2h, t2i)]]])
+      LogicalTableScan(table=[[default_catalog, default_database, t1, source: [TestTableSource(t1a, t1b, t1c, t1d, t1e, t1f, t1g, t1h, t1i)]]])
+})], variablesSet=[[$cor0]])
+   +- LogicalTableScan(table=[[default_catalog, default_database, t1, source: [TestTableSource(t1a, t1b, t1c, t1d, t1e, t1f, t1g, t1h, t1i)]]])
+]]>
+	</Resource>
+	<Resource name="optimized rel plan">

Review Comment:
   The query is 
   ```sql
   SELECT t1a
   FROM   t1
   WHERE  EXISTS (SELECT max(t2h) FROM t2
                  LEFT OUTER JOIN t1 ttt
                  ON t2.t2a=t1.t1a)
   ```
   inside `EXISTS` there is aggregate `MAX` which always returns a record. Even for empty table it returns a row with `null` inside. In this case `exists` is always `true`.
   The optimization does similar analysts based on metadata of the query.
   
   From this point of view it looks correct...
   Or did I miss anything?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1239069716


##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/rules/logical/subquery/SubqueryCorrelateVariablesValidationTest.scala:
##########
@@ -96,7 +96,7 @@ class SubqueryCorrelateVariablesValidationTest extends SubQueryTestBase {
     util.verifyRelPlan(sqlQuery)
   }
 
-  @Test(expected = classOf[TableException])
+  @Test

Review Comment:
   unexpected correlate variable $cor0 in the plan
   ```
   [ERROR] org.apache.flink.table.planner.plan.rules.logical.subquery.SubqueryCorrelateVariablesValidationTest.testWithFilterJoinCorrelate  Time elapsed: 0.036 s  <<< ERROR!
   org.apache.flink.table.api.TableException: unexpected correlate variable $cor0 in the plan
   	at org.apache.flink.table.planner.plan.optimize.program.FlinkDecorrelateProgram.checkCorrelVariableExists(FlinkDecorrelateProgram.scala:59)
   	at org.apache.flink.table.planner.plan.optimize.program.FlinkDecorrelateProgram.optimize(FlinkDecorrelateProgram.scala:42)
   	at org.apache.flink.table.planner.plan.optimize.program.FlinkChainedProgram.$anonfun$optimize$1(FlinkChainedProgram.scala:59)
   	at scala.collection.TraversableOnce.$anonfun$foldLeft$1(TraversableOnce.scala:156)
   	at scala.collection.TraversableOnce.$anonfun$foldLeft$1$adapted(TraversableOnce.scala:156)
   	at scala.collection.Iterator.foreach(Iterator.scala:937)
   	at scala.collection.Iterator.foreach$(Iterator.scala:937)
   	at scala.collection.AbstractIterator.foreach(Iterator.scala:1425)
   	at scala.collection.IterableLike.foreach(IterableLike.scala:70)
   	at scala.collection.IterableLike.foreach$(IterableLike.scala:69)
   	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
   	at scala.collection.TraversableOnce.foldLeft(TraversableOnce.scala:156)
   	at scala.collection.TraversableOnce.foldLeft$(TraversableOnce.scala:154)
   	at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104)
   	at org.apache.flink.table.planner.plan.optimize.program.FlinkChainedProgram.optimize(FlinkChainedProgram.scala:55)
   	at org.apache.flink.table.planner.plan.optimize.BatchCommonSubGraphBasedOptimizer.optimizeTree(BatchCommonSubGraphBasedOptimizer.scala:93)
   	at org.apache.flink.table.planner.plan.optimize.BatchCommonSubGraphBasedOptimizer.optimizeBlock(BatchCommonSubGraphBasedOptimizer.scala:58)
   	at org.apache.flink.table.planner.plan.optimize.BatchCommonSubGraphBasedOptimizer.$anonfun$doOptimize$1(BatchCommonSubGraphBasedOptimizer.scala:45)
   	at org.apache.flink.table.planner.plan.optimize.BatchCommonSubGraphBasedOptimizer.$anonfun$doOptimize$1$adapted(BatchCommonSubGraphBasedOptimizer.scala:45)
   	at scala.collection.immutable.List.foreach(List.scala:388)
   ...
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1190407800


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java:
##########
@@ -469,10 +469,10 @@ private static List<TestSetSpec> allTypesBasic() {
                         .fromCase(BIGINT(), DEFAULT_NEGATIVE_BIGINT, 539222987)
                         .fromCase(FLOAT(), DEFAULT_POSITIVE_FLOAT, 123)
                         .fromCase(FLOAT(), DEFAULT_NEGATIVE_FLOAT, -123)
-                        .fromCase(FLOAT(), 9234567891.12, 644633299)
+                        .fromCase(FLOAT(), 9234567891.12, 2147483647)

Review Comment:
   This looks a bit weird however after checking it the result is same as for
   ```java
   Float.parseFloat("9234567891.12");
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on PR #22558:
URL: https://github.com/apache/flink/pull/22558#issuecomment-1610234623

   Thanks a lot for taking a look @twalthr 
   
   It seems the problem with guava was that flink-sql-client makes it's own shading without relocation.
   I added relocation there within a couple of hotfix commits.
   
   I think since it is not directly related to Calcite Upgrade it should be merged as a separate hotfix commit (one hotfix commit). Please correct me if I'm wrong


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on PR #22558:
URL: https://github.com/apache/flink/pull/22558#issuecomment-1608451709

   rebased to solve conflicts and ci build issues


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1239018426


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java:
##########
@@ -526,7 +526,7 @@ private static List<TestSetSpec> allTypesBasic() {
                         .fromCase(BIGINT(), DEFAULT_NEGATIVE_BIGINT, DEFAULT_NEGATIVE_BIGINT)
                         .fromCase(FLOAT(), DEFAULT_POSITIVE_FLOAT, 123L)
                         .fromCase(FLOAT(), DEFAULT_NEGATIVE_FLOAT, -123L)
-                        .fromCase(FLOAT(), 9234567891.12, 9234567891L)
+                        .fromCase(FLOAT(), 9234567891.12, 9234568192L)

Review Comment:
   I've replaced it with 
   ```java
    .fromCase(FLOAT(), 9234567891.12, (long) 9234567891.12f)
    ```
     which also works



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1242916945


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java:
##########
@@ -1132,22 +1132,14 @@ private static List<TestSetSpec> numericBounds() {
                         .fromCase(DOUBLE(), -1.7976931348623157E308d, Float.NEGATIVE_INFINITY)
                         .build(),
                 CastTestSpecBuilder.testCastTo(DECIMAL(38, 0))
-                        .fromCase(TINYINT(), Byte.MIN_VALUE - 1, new BigDecimal(Byte.MIN_VALUE - 1))
-                        .fromCase(TINYINT(), Byte.MAX_VALUE + 1, new BigDecimal(Byte.MAX_VALUE + 1))
-                        .fromCase(
-                                SMALLINT(),
-                                Short.MIN_VALUE - 1,
-                                new BigDecimal(Short.MIN_VALUE - 1))
-                        .fromCase(
-                                SMALLINT(),
-                                Short.MAX_VALUE + 1,
-                                new BigDecimal(Short.MAX_VALUE + 1))
-                        .fromCase(
-                                INT(), Integer.MIN_VALUE - 1, new BigDecimal(Integer.MIN_VALUE - 1))
-                        .fromCase(
-                                INT(), Integer.MAX_VALUE + 1, new BigDecimal(Integer.MAX_VALUE + 1))
-                        .fromCase(BIGINT(), Long.MIN_VALUE - 1, new BigDecimal(Long.MIN_VALUE - 1))
-                        .fromCase(BIGINT(), Long.MAX_VALUE + 1, new BigDecimal(Long.MAX_VALUE + 1))
+                        .fromCase(TINYINT(), Byte.MIN_VALUE - 1, new BigDecimal(Byte.MAX_VALUE))

Review Comment:
   May be I didn't get what you mean... I added cast to `byte` for input however here expected type is `BigDecimal` since here it is cast to `DECIMAL(38, 0)`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] twalthr commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1213151859


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java:
##########
@@ -1132,22 +1132,14 @@ private static List<TestSetSpec> numericBounds() {
                         .fromCase(DOUBLE(), -1.7976931348623157E308d, Float.NEGATIVE_INFINITY)
                         .build(),
                 CastTestSpecBuilder.testCastTo(DECIMAL(38, 0))
-                        .fromCase(TINYINT(), Byte.MIN_VALUE - 1, new BigDecimal(Byte.MIN_VALUE - 1))
-                        .fromCase(TINYINT(), Byte.MAX_VALUE + 1, new BigDecimal(Byte.MAX_VALUE + 1))
-                        .fromCase(
-                                SMALLINT(),
-                                Short.MIN_VALUE - 1,
-                                new BigDecimal(Short.MIN_VALUE - 1))
-                        .fromCase(
-                                SMALLINT(),
-                                Short.MAX_VALUE + 1,
-                                new BigDecimal(Short.MAX_VALUE + 1))
-                        .fromCase(
-                                INT(), Integer.MIN_VALUE - 1, new BigDecimal(Integer.MIN_VALUE - 1))
-                        .fromCase(
-                                INT(), Integer.MAX_VALUE + 1, new BigDecimal(Integer.MAX_VALUE + 1))
-                        .fromCase(BIGINT(), Long.MIN_VALUE - 1, new BigDecimal(Long.MIN_VALUE - 1))
-                        .fromCase(BIGINT(), Long.MAX_VALUE + 1, new BigDecimal(Long.MAX_VALUE + 1))
+                        .fromCase(TINYINT(), Byte.MIN_VALUE - 1, new BigDecimal(Byte.MAX_VALUE))

Review Comment:
   I feel these tests are also kind of pointless if the subtraction and addition is not executed in SQL. If we would cast both input and expected results to `byte` it would make more sense.



##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/stream/table/CalcTest.xml:
##########
@@ -107,14 +107,14 @@ Calc(select=[*org.apache.flink.table.planner.expressions.utils.Func24$$2da7dcb3c
   <TestCase name="testNotIn">
     <Resource name="ast">
       <![CDATA[
-LogicalFilter(condition=[OR(SEARCH($1, Sarg[(-∞..1), (1..2), (2..3), (3..4), (4..5), (5..6), (6..7), (7..8), (8..9), (9..10), (10..11), (11..12), (12..13), (13..14), (14..15), (15..16), (16..17), (17..18), (18..19), (19..20), (20..21), (21..22), (22..23), (23..24), (24..25), (25..26), (26..27), (27..28), (28..29), (29..30), (30..+∞)]), SEARCH($2, Sarg[(-∞.._UTF-16LE'xx'), (_UTF-16LE'xx'..+∞)]:CHAR(2) CHARACTER SET "UTF-16LE"))])
+LogicalFilter(condition=[OR(SEARCH($1, Sarg[(-∞..1), (1..2), (2..3), (3..4), (4..5), (5..6), (6..7), (7..8), (8..9), (9..10), (10..11), (11..12), (12..13), (13..14), (14..15), (15..16), (16..17), (17..18), (18..19), (19..20), (20..21), (21..22), (22..23), (23..24), (24..25), (25..26), (26..27), (27..28), (28..29), (29..30), (30..+∞)]), <>($2, _UTF-16LE'xx'))])

Review Comment:
   Is CALCITE-5134 really the right issue for this diff? Doesn't look related. But the plan makes sense.



##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/rules/logical/subquery/SubqueryCorrelateVariablesValidationTest.scala:
##########
@@ -96,7 +96,7 @@ class SubqueryCorrelateVariablesValidationTest extends SubQueryTestBase {
     util.verifyRelPlan(sqlQuery)
   }
 
-  @Test(expected = classOf[TableException])
+  @Test

Review Comment:
   what was the exception before?



##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/rules/logical/subquery/SubqueryCorrelateVariablesValidationTest.xml:
##########
@@ -99,4 +99,34 @@ LogicalProject(min_t3d=[$9], max_t2h=[$11])
 ]]>
     </Resource>
   </TestCase>
+  <TestCase name="testWithFilterJoinCorrelate">
+	<Resource name="sql">
+			<![CDATA[
+SELECT t1a
+FROM   t1
+WHERE  EXISTS (SELECT max(t2h) FROM t2
+               LEFT OUTER JOIN t1 ttt
+               ON t2.t2a=t1.t1a)
+      ]]>
+	</Resource>
+	<Resource name="ast">
+			<![CDATA[
+LogicalProject(t1a=[$0])
++- LogicalFilter(condition=[EXISTS({
+LogicalAggregate(group=[{}], EXPR$0=[MAX($0)])
+  LogicalProject(t2h=[$7])
+    LogicalJoin(condition=[=($0, $cor0.t1a)], joinType=[left])
+      LogicalTableScan(table=[[default_catalog, default_database, t2, source: [TestTableSource(t2a, t2b, t2c, t2d, t2e, t2f, t2g, t2h, t2i)]]])
+      LogicalTableScan(table=[[default_catalog, default_database, t1, source: [TestTableSource(t1a, t1b, t1c, t1d, t1e, t1f, t1g, t1h, t1i)]]])
+})], variablesSet=[[$cor0]])
+   +- LogicalTableScan(table=[[default_catalog, default_database, t1, source: [TestTableSource(t1a, t1b, t1c, t1d, t1e, t1f, t1g, t1h, t1i)]]])
+]]>
+	</Resource>
+	<Resource name="optimized rel plan">

Review Comment:
   This looks incorrect to me. Did some rules don't fire correctly? Or is this really the correct optimization?



##########
flink-table/flink-sql-jdbc-driver/pom.xml:
##########
@@ -84,6 +84,12 @@
 			<version>${project.version}</version>
 			<scope>test</scope>
 		</dependency>
+		<dependency>
+			<groupId>com.google.guava</groupId>
+			<artifactId>guava</artifactId>
+			<version>${guava.version}</version>
+			<scope>provided</scope>
+		</dependency>

Review Comment:
   Isn't this a problem of `FlinkSqlParserImpl`? Maybe the parser uses Guava for the first time and we don't declare the dependencies correctly?



##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java:
##########
@@ -469,10 +469,10 @@ private static List<TestSetSpec> allTypesBasic() {
                         .fromCase(BIGINT(), DEFAULT_NEGATIVE_BIGINT, 539222987)
                         .fromCase(FLOAT(), DEFAULT_POSITIVE_FLOAT, 123)
                         .fromCase(FLOAT(), DEFAULT_NEGATIVE_FLOAT, -123)
-                        .fromCase(FLOAT(), 9234567891.12, 644633299)
+                        .fromCase(FLOAT(), 9234567891.12, 2147483647)

Review Comment:
   Great that it got fixed in Calcite but this is a pretty significant change. We need to properly communicate this via release notes.



##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java:
##########
@@ -526,7 +526,7 @@ private static List<TestSetSpec> allTypesBasic() {
                         .fromCase(BIGINT(), DEFAULT_NEGATIVE_BIGINT, DEFAULT_NEGATIVE_BIGINT)
                         .fromCase(FLOAT(), DEFAULT_POSITIVE_FLOAT, 123L)
                         .fromCase(FLOAT(), DEFAULT_NEGATIVE_FLOAT, -123L)
-                        .fromCase(FLOAT(), 9234567891.12, 9234567891L)
+                        .fromCase(FLOAT(), 9234567891.12, 9234568192L)

Review Comment:
   can we change the FLOAT lines to `9234567891.12f` or `Float.parseFloat("9234567891.12");` because the test uses doubles instead of floats. This is confusing.



##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/DagOptimizationTest.xml:
##########
@@ -379,30 +382,30 @@ LogicalLegacySink(name=[`default_catalog`.`default_database`.`retractSink2`], fi
       <![CDATA[
 LegacySink(name=[`default_catalog`.`default_database`.`retractSink1`], fields=[a, total_c], changelogMode=[NONE])
 +- Union(all=[true], union=[a, total_c], changelogMode=[I,UB,UA])
-   :- Calc(select=[a, total_c], where=[>(a, 50)], changelogMode=[I,UB,UA])
-   :  +- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
-   :     +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT c) AS total_c], changelogMode=[I,UB,UA])
-   :        +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
-   :           +- Calc(select=[a, b, f0 AS c], changelogMode=[I])
-   :              +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
-   :                 +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[AND(>=(b, UNIX_TIMESTAMP('${startTime}')), <>(c, ''))], changelogMode=[I])
+   :- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
+   :  +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT f0) AS total_c], changelogMode=[I,UB,UA])
+   :     +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
+   :        +- Calc(select=[a, b, f0], where=[>(a, 50)], changelogMode=[I])
+   :           +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
+   :              +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[<>(c, '')], changelogMode=[I])
+   :                 +- Calc(select=[a, b, c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])

Review Comment:
   Two calc after each other?



##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java:
##########
@@ -526,7 +526,7 @@ private static List<TestSetSpec> allTypesBasic() {
                         .fromCase(BIGINT(), DEFAULT_NEGATIVE_BIGINT, DEFAULT_NEGATIVE_BIGINT)
                         .fromCase(FLOAT(), DEFAULT_POSITIVE_FLOAT, 123L)
                         .fromCase(FLOAT(), DEFAULT_NEGATIVE_FLOAT, -123L)
-                        .fromCase(FLOAT(), 9234567891.12, 9234567891L)
+                        .fromCase(FLOAT(), 9234567891.12, 9234568192L)

Review Comment:
   These are pretty significant changes :(



##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/batch/sql/DagOptimizationTest.xml:
##########
@@ -478,33 +483,37 @@ LogicalLegacySink(name=[`default_catalog`.`default_database`.`sink3`], fields=[t
     </Resource>
     <Resource name="optimized exec plan">
       <![CDATA[
-Union(all=[true], union=[a, c])(reuse_id=[1])
-:- Calc(select=[a, c])
-:  +- LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c])
-+- Calc(select=[d, f])
-   +- LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable1, source: [TestTableSource(d, e, f)]]], fields=[d, e, f])
+LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c])(reuse_id=[1])
+
+LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable1, source: [TestTableSource(d, e, f)]]], fields=[d, e, f])(reuse_id=[2])
 
 LegacySink(name=[`default_catalog`.`default_database`.`sink1`], fields=[a, c])
-+- Reused(reference_id=[1])
++- Union(all=[true], union=[a, c])
+   :- Calc(select=[a, c])
+   :  +- Reused(reference_id=[1])
+   +- Calc(select=[d, f])

Review Comment:
   why this?



##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/DagOptimizationTest.xml:
##########
@@ -379,30 +382,30 @@ LogicalLegacySink(name=[`default_catalog`.`default_database`.`retractSink2`], fi
       <![CDATA[
 LegacySink(name=[`default_catalog`.`default_database`.`retractSink1`], fields=[a, total_c], changelogMode=[NONE])
 +- Union(all=[true], union=[a, total_c], changelogMode=[I,UB,UA])
-   :- Calc(select=[a, total_c], where=[>(a, 50)], changelogMode=[I,UB,UA])
-   :  +- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
-   :     +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT c) AS total_c], changelogMode=[I,UB,UA])
-   :        +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
-   :           +- Calc(select=[a, b, f0 AS c], changelogMode=[I])
-   :              +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
-   :                 +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[AND(>=(b, UNIX_TIMESTAMP('${startTime}')), <>(c, ''))], changelogMode=[I])
+   :- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
+   :  +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT f0) AS total_c], changelogMode=[I,UB,UA])
+   :     +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
+   :        +- Calc(select=[a, b, f0], where=[>(a, 50)], changelogMode=[I])
+   :           +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
+   :              +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[<>(c, '')], changelogMode=[I])
+   :                 +- Calc(select=[a, b, c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])
    :                    +- LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c], changelogMode=[I])
-   +- Calc(select=[a, CAST(total_c AS BIGINT) AS total_c], where=[>(a, 50)], changelogMode=[I])
-      +- Calc(select=[a, 0 AS total_c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])
+   +- Calc(select=[a, 0 AS total_c], where=[>(a, 50)], changelogMode=[I])
+      +- Calc(select=[a, b, c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])
          +- LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c], changelogMode=[I])
 
 LegacySink(name=[`default_catalog`.`default_database`.`retractSink2`], fields=[a, total_c], changelogMode=[NONE])
 +- Union(all=[true], union=[a, total_c], changelogMode=[I,UB,UA])
-   :- Calc(select=[a, total_c], where=[<(a, 50)], changelogMode=[I,UB,UA])
-   :  +- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
-   :     +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT c) AS total_c], changelogMode=[I,UB,UA])
-   :        +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
-   :           +- Calc(select=[a, b, f0 AS c], changelogMode=[I])
-   :              +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
-   :                 +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[AND(>=(b, UNIX_TIMESTAMP('${startTime}')), <>(c, ''))], changelogMode=[I])
+   :- Calc(select=[a, total_c], changelogMode=[I,UB,UA])
+   :  +- GroupAggregate(groupBy=[a, b], select=[a, b, COUNT(DISTINCT f0) AS total_c], changelogMode=[I,UB,UA])
+   :     +- Exchange(distribution=[hash[a, b]], changelogMode=[I])
+   :        +- Calc(select=[a, b, f0], where=[<(a, 50)], changelogMode=[I])
+   :           +- Correlate(invocation=[split($cor0.c)], correlate=[table(split($cor0.c))], select=[a,b,c,f0], rowType=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c, VARCHAR(2147483647) f0)], joinType=[INNER], changelogMode=[I])
+   :              +- Calc(select=[a, -(b, MOD(b, 300)) AS b, c], where=[<>(c, '')], changelogMode=[I])
+   :                 +- Calc(select=[a, b, c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])
    :                    +- LegacyTableSourceScan(table=[[default_catalog, default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c], changelogMode=[I])
-   +- Calc(select=[a, CAST(total_c AS BIGINT) AS total_c], where=[<(a, 50)], changelogMode=[I])
-      +- Calc(select=[a, 0 AS total_c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])
+   +- Calc(select=[a, 0 AS total_c], where=[<(a, 50)], changelogMode=[I])
+      +- Calc(select=[a, b, c], where=[>=(b, UNIX_TIMESTAMP('${startTime}'))], changelogMode=[I])

Review Comment:
   shouldn't `select=[a, b, c]` be `select=[a]`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on PR #22558:
URL: https://github.com/apache/flink/pull/22558#issuecomment-1541882773

   
   @melin in FLINK-27998 it was decided to go step by step (version by version)
   Each upgrade (for every Calcite version) has it's own JIRA issue
   
   In case you want to play with 1.34.0 I have a test branch with 1.34.0 Calcite https://github.com/apache/flink/pull/20922
   however since it's used for test purposes it could be unstable sometimes


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1190411735


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java:
##########
@@ -469,10 +469,10 @@ private static List<TestSetSpec> allTypesBasic() {
                         .fromCase(BIGINT(), DEFAULT_NEGATIVE_BIGINT, 539222987)
                         .fromCase(FLOAT(), DEFAULT_POSITIVE_FLOAT, 123)
                         .fromCase(FLOAT(), DEFAULT_NEGATIVE_FLOAT, -123)
-                        .fromCase(FLOAT(), 9234567891.12, 644633299)
+                        .fromCase(FLOAT(), 9234567891.12, 2147483647)

Review Comment:
   All the changes is this file are a consequence of https://issues.apache.org/jira/browse/CALCITE-4861



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1190413352


##########
flink-table/flink-sql-jdbc-driver/pom.xml:
##########
@@ -84,6 +84,12 @@
 			<version>${project.version}</version>
 			<scope>test</scope>
 		</dependency>
+		<dependency>
+			<groupId>com.google.guava</groupId>
+			<artifactId>guava</artifactId>
+			<version>${guava.version}</version>
+			<scope>provided</scope>
+		</dependency>

Review Comment:
   Suddenly with Calcite 1.31.0 it starts failing with guava's `ImmutableList` not found. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] snuyanzin commented on a diff in pull request #22558: [FLINK-28744][table] Upgrade Calcite to 1.31.0

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #22558:
URL: https://github.com/apache/flink/pull/22558#discussion_r1190413352


##########
flink-table/flink-sql-jdbc-driver/pom.xml:
##########
@@ -84,6 +84,12 @@
 			<version>${project.version}</version>
 			<scope>test</scope>
 		</dependency>
+		<dependency>
+			<groupId>com.google.guava</groupId>
+			<artifactId>guava</artifactId>
+			<version>${guava.version}</version>
+			<scope>provided</scope>
+		</dependency>

Review Comment:
   Suddenly with Calcite 1.31.0 it starts failing with guava's `ImmutableList/Map` not found. 
   like 
   ```
   Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap
   	at org.apache.flink.sql.parser.impl.FlinkSqlParserImpl.setTimeUnitCodes(FlinkSqlParserImpl.java:296)
   	at org.apache.calcite.sql.parser.SqlParser.<init>(SqlParser.java:73)
   	at org.apache.calcite.sql.parser.SqlParser.create(SqlParser.java:126)
   	at org.apache.calcite.sql.parser.SqlParser.create(SqlParser.java:105)
   	at org.apache.flink.table.planner.parse.CalciteParser.parseSqlList(CalciteParser.java:75)
   	at org.apache.flink.table.planner.delegation.ParserImpl.parse(ParserImpl.java:102)
   	at org.apache.flink.table.gateway.service.operation.OperationExecutor.executeStatement(OperationExecutor.java:186)
   	at org.apache.flink.table.gateway.service.SqlGatewayServiceImpl.lambda$executeStatement$1(SqlGatewayServiceImpl.java:212)
   	at org.apache.flink.table.gateway.service.operation.OperationManager.lambda$submitOperation$1(OperationManager.java:119)
   	at org.apache.flink.table.gateway.service.operation.OperationManager$Operation.lambda$run$0(OperationManager.java:258)
   	... 7 more
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org