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 2026/06/02 07:31:09 UTC

[PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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

   ## What is the purpose of the change
   
   Bumping Calcite to 1.39.0
   **The PR is based on top of [[FLINK-36602][table] Upgrade Calcite to 1.38.0](https://github.com/apache/flink/pull/28170 )**
   ## Brief change log
   pom, NOTICE, Calcite classes
   
   ## Verifying this change
   Existing 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)`: ( no)
     - 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)
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, please
   change the checkbox below to `[X]` followed by the name of the tool, and uncomment the
   "Generated-by" line. See the ASF Generative Tooling Guidance for details:
   https://www.apache.org/legal/generative-tooling.html
   
   You are responsible for the quality and correctness of every change in this PR
   regardless of the tooling used. Low-effort AI-generated PRs will be closed. See
   AGENTS.md for the full guidance.
   -->
   
   - [ ] Yes (please specify the tool below)
   
   <!--
   Generated-by: [Tool Name and Version]
   -->
   


-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-sql-parser/src/main/codegen/templates/Parser.jj:
##########
@@ -1159,7 +1159,7 @@ SqlNode SqlStmt() :
         LOOKAHEAD(2) stmt = ${method}
     |
 </#list>
-        stmt = SqlSetOption(Span.of(), null)
+        stmt = ${parser.setOptionParserMethod!default.parser.setOptionParserMethod}(Span.of(), null)

Review Comment:
   sync with Calcite



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/batch/sql/DynamicFunctionPlanTest.xml:
##########
@@ -34,10 +34,11 @@ LogicalAggregate(group=[{0, 1}], EXPR$2=[SUM($2)], EXPR$3=[COUNT()])
     </Resource>
     <Resource name="optimized exec plan">
       <![CDATA[
-HashAggregate(isMerge=[false], groupBy=[cat], auxGrouping=[gmt_date], select=[cat, gmt_date, SUM(cnt) AS EXPR$2, COUNT(*) AS EXPR$3])
-+- Exchange(distribution=[hash[cat]])
-   +- Calc(select=[cat, gmt_date, cnt], where=[(gmt_date = CURRENT_DATE())])
-      +- TableSourceScan(table=[[default_catalog, default_database, src, filter=[], project=[cat, gmt_date, cnt], metadata=[]]], fields=[cat, gmt_date, cnt])
+Calc(select=[cat, CAST(CURRENT_DATE() AS DATE) AS gmt_date, EXPR$2, EXPR$3])

Review Comment:
   This is test for batch 
   we have these kind of tests running both for batch and stream both extending `DynamicFunctionPlanTestBase` (https://github.com/snuyanzin/flink/blob/6aadeddbc5ede604c95be2d6fea2557e49ae5330/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/common/DynamicFunctionPlanTestBase.java)
   
   like for batch https://github.com/snuyanzin/flink/blob/6aadeddbc5ede604c95be2d6fea2557e49ae5330/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/batch/sql/DynamicFunctionPlanTest.java 
   
   and for stream https://github.com/snuyanzin/flink/blob/6aadeddbc5ede604c95be2d6fea2557e49ae5330/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/stream/sql/DynamicFunctionPlanTest.java
   
   the plan for stream is unchanged in this PR
   https://github.com/snuyanzin/flink/blob/6aadeddbc5ede604c95be2d6fea2557e49ae5330/flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/DynamicFunctionPlanTest.xml#L19-L41



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##########
@@ -187,39 +187,39 @@
  * <p>Lines 241 ~ 244, Flink improves error message for functions without appropriate arguments in
  * handleUnresolvedFunction.
  *
- * <p>Lines 1378 ~ 1380, CALCITE-7217, should be removed after upgrading Calcite to 1.41.0.
+ * <p>Lines 1390 ~ 1392, CALCITE-7217, should be removed after upgrading Calcite to 1.41.0.

Review Comment:
   sync with Calcite



##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql/SqlUtil.java:
##########
@@ -77,7 +77,7 @@
 /**
  * Flink modification because of CALCITE-7027
  *
- * <p>Lines 827 ~ 833, should be removed after upgrading to 1.40.
+ * <p>Lines 830 ~ 836, should be removed after upgrading to 1.40.

Review Comment:
   sync with Calcite



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin closed pull request #28290: [FLINK-39817][table] Upgrade Calcite version to 1.39.0
URL: https://github.com/apache/flink/pull/28290


-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-sql-parser/src/test/java/org/apache/flink/sql/parser/FlinkDDLDataTypeTest.java:
##########
@@ -546,7 +546,11 @@ public void checkUnparsed(String sql, String expectedUnparsed) {
             SqlNodeList columns = sqlCreateTable.getColumnList();
             assertThat(columns.size()).isEqualTo(1);
             SqlDataTypeSpec dataTypeSpec = ((SqlRegularColumn) columns.get(0)).getType();
-            SqlWriter sqlWriter = new SqlPrettyWriter(factory.createSqlDialect(), false);
+            SqlWriter sqlWriter =

Review Comment:
   just replace deprecated constructor



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/rel/rules/SubQueryRemoveRule.java:
##########
@@ -27,6 +27,7 @@
 import org.apache.calcite.rel.core.Join;
 import org.apache.calcite.rel.core.JoinRelType;
 import org.apache.calcite.rel.core.Project;
+import org.apache.calcite.rel.metadata.RelMdUtil;

Review Comment:
   sync with Calcite



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-sql-parser/src/main/codegen/templates/Parser.jj:
##########
@@ -4891,6 +4890,11 @@ SqlLiteral DateTimeLiteral() :
     <TIME> { s = span(); } p = SimpleStringLiteral() {
       return SqlLiteral.createUnknown("TIME", p, s.end(this));
     }
+|
+    LOOKAHEAD(2)
+    <UUID> { s = span(); } p = SimpleStringLiteral() {

Review Comment:
   new type , however doesn't go further without support in FlinkTypeFactory.
   
   Queries with uuid function seems still continue working



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/batch/sql/DynamicFunctionPlanTest.xml:
##########
@@ -34,10 +34,11 @@ LogicalAggregate(group=[{0, 1}], EXPR$2=[SUM($2)], EXPR$3=[COUNT()])
     </Resource>
     <Resource name="optimized exec plan">
       <![CDATA[
-HashAggregate(isMerge=[false], groupBy=[cat], auxGrouping=[gmt_date], select=[cat, gmt_date, SUM(cnt) AS EXPR$2, COUNT(*) AS EXPR$3])
-+- Exchange(distribution=[hash[cat]])
-   +- Calc(select=[cat, gmt_date, cnt], where=[(gmt_date = CURRENT_DATE())])
-      +- TableSourceScan(table=[[default_catalog, default_database, src, filter=[], project=[cat, gmt_date, cnt], metadata=[]]], fields=[cat, gmt_date, cnt])
+Calc(select=[cat, CAST(CURRENT_DATE() AS DATE) AS gmt_date, EXPR$2, EXPR$3])

Review Comment:
   This is test for batch 
   we have these kind of tests running both for batch and stream both extending `DynamicFunctionPlanTestBase` (https://github.com/snuyanzin/flink/blob/6aadeddbc5ede604c95be2d6fea2557e49ae5330/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/common/DynamicFunctionPlanTestBase.java)
   like for batch https://github.com/snuyanzin/flink/blob/6aadeddbc5ede604c95be2d6fea2557e49ae5330/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/batch/sql/DynamicFunctionPlanTest.java and for stream https://github.com/snuyanzin/flink/blob/6aadeddbc5ede604c95be2d6fea2557e49ae5330/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/stream/sql/DynamicFunctionPlanTest.java
   
   the plan for stream is unchanged in this PR
   https://github.com/snuyanzin/flink/blob/6aadeddbc5ede604c95be2d6fea2557e49ae5330/flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/DynamicFunctionPlanTest.xml#L19-L41



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/batch/sql/SetOperatorsTest.xml:
##########
@@ -131,7 +131,7 @@ LogicalProject(a=[$0])
 Calc(select=[a])
 +- HashAggregate(isMerge=[false], groupBy=[a, b], select=[a, b])
    +- Exchange(distribution=[keep_input_as_is[hash[a, b]]])
-      +- HashJoin(joinType=[LeftSemiJoin], where=[(((a = d) OR (a IS NULL AND d IS NULL)) AND ((b = e) OR (b IS NULL AND e IS NULL)))], select=[a, b], build=[right])
+      +- HashJoin(joinType=[LeftSemiJoin], where=[(IS NOT DISTINCT FROM(a, d) AND IS NOT DISTINCT FROM(b, e))], select=[a, b], build=[right])

Review Comment:
   optimization from https://issues.apache.org/jira/browse/CALCITE-6776



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql/type/SqlTypeFactoryImpl.java:
##########
@@ -39,10 +40,8 @@
  * <p>FLINK modifications are at lines
  *
  * <ol>
- *   <li>Should be removed after fixing CALCITE-6342: Lines 113-115
- *   <li>Added in FLINK-39695 (backport of CALCITE-6764): Lines 243 ~ 266
- *   <li>Should be removed after fix of FLINK-31350: Lines 527-539.
- *   <li>Should be removed after fixing CALCITE-6342: Lines 606-618
+ *   <li>Should be removed after fixing CALCITE-6342: Lines 527-529.

Review Comment:
   sync with Calcite



##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java:
##########
@@ -89,7 +89,7 @@ public abstract class SqlTypeUtil {
      *     same charset and collation of same charset
      */
     public static boolean isCharTypeComparable(List<RelDataType> argTypes) {
-        assert argTypes != null;
+        requireNonNull(argTypes, "argTypes");

Review Comment:
   sync with Calcite



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-sql-parser/src/main/codegen/templates/Parser.jj:
##########
@@ -6428,59 +6441,56 @@ SqlNode BuiltinFunctionCall() :
         <TRIM> {
             SqlLiteral flag = null;
             SqlNode trimChars = null;
+            SqlParserPos fromPos = SqlParserPos.ZERO;
             s = span();
         }
         <LPAREN>
-        [
-            LOOKAHEAD(2)
-            [
-                <BOTH> {
-                    s.add(this);
-                    flag = SqlTrimFunction.Flag.BOTH.symbol(getPos());
-                }
-            |
-                <TRAILING> {
-                    s.add(this);
-                    flag = SqlTrimFunction.Flag.TRAILING.symbol(getPos());
-                }
-            |
-                <LEADING> {
-                    s.add(this);
-                    flag = SqlTrimFunction.Flag.LEADING.symbol(getPos());
-                }
-            ]
-            [ trimChars = Expression(ExprContext.ACCEPT_SUB_QUERY) ]
+        (
             (
-                <FROM> {
-                    if (null == flag && null == trimChars) {
-                        throw SqlUtil.newContextException(getPos(),
-                            RESOURCE.illegalFromEmpty());
+                (
+                    <BOTH> {
+                        s.add(this);
+                        flag = SqlTrimFunction.Flag.BOTH.symbol(getPos());
                     }
-                }
-            |
-                <RPAREN> {
-                    // This is to handle the case of TRIM(x)
-                    // (FRG-191).
-                    if (flag == null) {
-                        flag = SqlTrimFunction.Flag.BOTH.symbol(SqlParserPos.ZERO);
+                |
+                    <TRAILING> {
+                        s.add(this);
+                        flag = SqlTrimFunction.Flag.TRAILING.symbol(getPos());
                     }
-                    args.add(flag);
-                    args.add(null); // no trim chars
-                    args.add(trimChars); // reinterpret trimChars as source
-                    return SqlStdOperatorTable.TRIM.createCall(s.end(this),
-                        args);
-                }
+                |
+                    <LEADING> {
+                        s.add(this);
+                        flag = SqlTrimFunction.Flag.LEADING.symbol(getPos());
+                    }
+                )
+                (
+                    <FROM> { fromPos = getPos() ;}
+                    e = Expression(ExprContext.ACCEPT_SUB_QUERY)
+                |
+                    e = Expression(ExprContext.ACCEPT_SUB_QUERY)
+                    [
+                        <FROM> { trimChars = e; fromPos = getPos(); }
+                        e = Expression(ExprContext.ACCEPT_SUB_QUERY)
+                    ]
+                )

Review Comment:
   cherry-pick from https://issues.apache.org/jira/browse/CALCITE-7565
   to fix regression of 1.39.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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/rules/logical/subquery/SubQueryAntiJoinTest.xml:
##########
@@ -65,6 +65,64 @@ LogicalProject(a=[$0], b=[$1], c=[$2])
    +- LogicalProject(e=[$1])
       +- LogicalFilter(condition=[true])
          +- LogicalTableScan(table=[[default_catalog, default_database, r]])
+]]>
+    </Resource>
+  </TestCase>
+  <TestCase name="testInNotInExistsNotExists2">

Review Comment:
   now several queries started to work rather than failing



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/validate/FlinkSqlConformance.java:
##########
@@ -172,6 +182,11 @@ public boolean allowLenientCoercion() {
         return SqlConformanceEnum.DEFAULT.allowLenientCoercion();
     }
 
+    @Override
+    public boolean checkedArithmetic() {
+        return SqlConformanceEnum.DEFAULT.checkedArithmetic();
+    }
+

Review Comment:
   so may be makes sense to enable in Flink at some point (separately)



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/rex/RexBuilder.java:
##########
@@ -86,10 +87,6 @@
  * Factory for row expressions.
  *
  * <p>Some common literal values (NULL, TRUE, FALSE, 0, 1, '') are cached.
- *
- * <p>FLINK modifications (backport of CALCITE-6764): Lines 237, 243, 247, 251 ~ 255
- *
- * <p>FLINK modifications (backport of FLINK-39945): Lines 1270-1284

Review Comment:
   true, updated comments: CALCITE-6764 should be removed as it is fixed now



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/jdbc/SimpleCalciteSchema.java:
##########
@@ -133,38 +133,8 @@ public CalciteSchema add(String name, Schema schema) {
     }
 
     @Override
-    protected @Nullable CalciteSchema getImplicitSubSchema(
-            String schemaName, boolean caseSensitive) {
-        // Check implicit schemas.
-        final String schemaName2 =
-                caseSensitive
-                        ? schemaName
-                        : caseInsensitiveLookup(schema.getSubSchemaNames(), schemaName);
-        if (schemaName2 == null) {
-            return null;
-        }
-        final Schema s = schema.getSubSchema(schemaName2);
-        if (s == null) {
-            return null;
-        }
-        return new SimpleCalciteSchema(this, s, schemaName2);
-    }
-
-    @Override
-    protected @Nullable TableEntry getImplicitTable(String tableName, boolean caseSensitive) {
-        // Check implicit tables.
-        final String tableName2 =
-                caseSensitive
-                        ? tableName
-                        : caseInsensitiveLookup(schema.getTableNames(), tableName);
-        if (tableName2 == null) {
-            return null;
-        }
-        final Table table = schema.getTable(tableName2);
-        if (table == null) {
-            return null;
-        }
-        return tableEntry(tableName2, table);
+    protected CalciteSchema createSubSchema(Schema schema, String name) {

Review Comment:
   sync with Calcite



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/validate/FlinkSqlConformance.java:
##########
@@ -117,6 +122,11 @@ public boolean allowNiladicParentheses() {
         return true;
     }
 
+    @Override
+    public boolean allowNiladicConstantWithoutParentheses() {
+        return true;
+    }

Review Comment:
   as mentioned in Calcite's javadoc
   ```
      * Whether to allow parentheses to be specified in calls to niladic functions of
      * returned the specific constant value.
      *
      * <p>For example, {@code PI} is a niladic function and return specific constant values pi.
      * In standard SQL it must be invoked with parentheses:
      *
      * <blockquote><code>VALUES PI()</code></blockquote>
      *
      * <p>If {@code allowNiladicConstantWithoutParentheses}, the following syntax is also valid:
   ```
   https://github.com/apache/calcite/blob/1219091d2b76ccb1dfaa6f1f02c89c2a9ed5e532/core/src/main/java/org/apache/calcite/sql/validate/SqlConformance.java#L410-L432



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/validate/FlinkSqlConformance.java:
##########
@@ -117,6 +122,11 @@ public boolean allowNiladicParentheses() {
         return true;
     }
 
+    @Override
+    public boolean allowNiladicConstantWithoutParentheses() {
+        return true;
+    }

Review Comment:
   as mentioned in Calcite's javadoc
   https://github.com/apache/calcite/blob/1219091d2b76ccb1dfaa6f1f02c89c2a9ed5e532/core/src/main/java/org/apache/calcite/sql/validate/SqlConformance.java#L410-L432



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql/SqlIntervalQualifier.java:
##########
@@ -44,26 +44,10 @@
 
 /**
  * The class copied from Calcite because of <a
- * href="https://issues.apache.org/jira/browse/CALCITE-6581">CALCITE-6581</a>. Lines:
+ * href="https://issues.apache.org/jira/browse/CALCITE-6345">CALCITE-6345</a>. Lines:

Review Comment:
   sync with Calcite



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/jdbc/SimpleCalciteSchema.java:
##########
@@ -133,38 +133,8 @@ public CalciteSchema add(String name, Schema schema) {
     }
 
     @Override
-    protected @Nullable CalciteSchema getImplicitSubSchema(
-            String schemaName, boolean caseSensitive) {
-        // Check implicit schemas.
-        final String schemaName2 =
-                caseSensitive
-                        ? schemaName
-                        : caseInsensitiveLookup(schema.getSubSchemaNames(), schemaName);
-        if (schemaName2 == null) {
-            return null;
-        }
-        final Schema s = schema.getSubSchema(schemaName2);
-        if (s == null) {
-            return null;
-        }
-        return new SimpleCalciteSchema(this, s, schemaName2);
-    }
-
-    @Override
-    protected @Nullable TableEntry getImplicitTable(String tableName, boolean caseSensitive) {
-        // Check implicit tables.
-        final String tableName2 =
-                caseSensitive
-                        ? tableName
-                        : caseInsensitiveLookup(schema.getTableNames(), tableName);
-        if (tableName2 == null) {
-            return null;
-        }
-        final Table table = schema.getTable(tableName2);
-        if (table == null) {
-            return null;
-        }
-        return tableEntry(tableName2, table);
+    protected CalciteSchema createSubSchema(Schema schema, String name) {

Review Comment:
   sync with Calcite



##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/rel/rules/SubQueryRemoveRule.java:
##########
@@ -161,6 +162,12 @@ private static RexNode rewriteCollection(
      */
     private static RexNode rewriteSome(
             RexSubQuery e, Set<CorrelationId> variablesSet, RelBuilder builder, int subQueryIndex) {
+        // If the sub-query is guaranteed empty, just return

Review Comment:
   sync with Calcite



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql/type/BasicSqlType.java:
##########
@@ -144,7 +144,7 @@ protected static void checkPrecScale(
     // ~ Methods ----------------------------------------------------------------
 
     /** Constructs a type with nullablity. */
-    BasicSqlType createWithNullability(boolean nullable) {
+    public BasicSqlType createWithNullability(boolean nullable) {

Review Comment:
   sync with Calcite



##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql/type/SqlTypeAssignmentRule.java:
##########
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.calcite.sql.type;

Review Comment:
   sync with Calcite



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql2rel/AggConverter.java:
##########
@@ -69,7 +69,7 @@
  * FLINK modifications are at lines
  *
  * <ol>
- *   <li>Added in FLINK-34057, FLINK-34058, FLINK-34312: Lines 452 ~ 469
+ *   <li>Added in FLINK-34057, FLINK-34058, FLINK-34312: Lines 465 ~ 482

Review Comment:
   sync with Calcite



##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java:
##########
@@ -18,6 +18,7 @@
 
 import org.apache.flink.table.planner.plan.rules.logical.FlinkFilterProjectTransposeRule;
 
+import com.google.common.collect.ImmutableList;

Review Comment:
   sync with Calcite



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/rel/type/RelDataTypeFactoryImpl.java:
##########
@@ -58,8 +58,8 @@
  * <p>FLINK modifications are at lines
  *
  * <ol>
- *   <li>Should be removed after fixing CALCITE-5199: Lines 242-244
- *   <li>Added in FLINK-39695 (backport of CALCITE-6764): Lines 407 ~ 438
+ *   <li>Should be removed after fixing CALCITE-5199: Lines 241-243
+ *   <li>Preserve FLOAT precision as in Calcite 1.38.0: Lines 592 ~ 594

Review Comment:
   sync with Calcite



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/validate/FlinkSqlConformance.java:
##########
@@ -172,6 +182,11 @@ public boolean allowLenientCoercion() {
         return SqlConformanceEnum.DEFAULT.allowLenientCoercion();
     }
 
+    @Override
+    public boolean checkedArithmetic() {
+        return SqlConformanceEnum.DEFAULT.checkedArithmetic();
+    }
+

Review Comment:
   `DEFAULT` here means disabled
   
   Whether the implementation uses checked arithmetic. Most SQL dialects use checked arithmetic at runtime: they terminate with a fatal error on overflow.



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d5fe2102023884875fc162e3ecbcad8bd6780c14",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "d5fe2102023884875fc162e3ecbcad8bd6780c14",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * d5fe2102023884875fc162e3ecbcad8bd6780c14 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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java:
##########
@@ -90,7 +90,7 @@
  * Implementation of {@link org.apache.calcite.sql.SqlOperatorTable} containing the standard
  * operators and functions.
  *
- * <p>Lines 765 ~ 767, 785 ~ 787, 796 ~ 798, 807 ~ 809, 818 ~ 820, 829 ~ 831, 840 ~ 842, Flink
+ * <p>Lines 822 ~ 824, 842 ~ 844, 853 ~ 855, 864 ~ 866, 875 ~ 877, 886 ~ 888, 897 ~ 899, Flink

Review Comment:
   sync with Calcite



##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -120,13 +121,15 @@
 import java.util.Objects;
 import java.util.Set;
 import java.util.TimeZone;
+import java.util.UUID;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.function.BinaryOperator;
 import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
+import java.util.zip.CRC32;

Review Comment:
   sync with Calcite



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java:
##########
@@ -79,11 +79,10 @@
 import org.apache.calcite.rel.logical.LogicalTableFunctionScan;
 import org.apache.calcite.rel.logical.LogicalTableModify;
 import org.apache.calcite.rel.logical.LogicalTableScan;
-import org.apache.calcite.rel.logical.LogicalUnion;
 import org.apache.calcite.rel.logical.LogicalValues;
 import org.apache.calcite.rel.metadata.RelColumnMapping;
+import org.apache.calcite.rel.metadata.RelMdUtil;

Review Comment:
   sync with Calcite



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/rules/logical/WindowGroupReorderRule.java:
##########
@@ -134,9 +134,10 @@ public void onMatch(RelOptRuleCall call) {
             LogicalProject project =
                     LogicalProject.create(

Review Comment:
   replace depreacted method call



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-sql-parser/src/test/java/org/apache/flink/sql/parser/ExtendedSqlRowTypeNameSpecTest.java:
##########
@@ -92,12 +92,15 @@ private SqlWriter getSqlWriter() {
                         .withParserFactory((SqlParserImplFactory) options.get("parserFactory"));
 
         return new SqlPrettyWriter(
-                new CalciteSqlDialect(
-                        SqlDialect.EMPTY_CONTEXT
-                                .withQuotedCasing(parserConfig.unquotedCasing())
-                                .withConformance(parserConfig.conformance())
-                                .withUnquotedCasing(parserConfig.unquotedCasing())
-                                .withIdentifierQuoteString(parserConfig.quoting().string)),
-                false);
+                SqlPrettyWriter.config()

Review Comment:
   just replace deprecated constructor



##########
flink-table/flink-sql-parser/src/test/java/org/apache/flink/sql/parser/FlinkDDLDataTypeTest.java:
##########
@@ -546,7 +546,11 @@ public void checkUnparsed(String sql, String expectedUnparsed) {
             SqlNodeList columns = sqlCreateTable.getColumnList();
             assertThat(columns.size()).isEqualTo(1);
             SqlDataTypeSpec dataTypeSpec = ((SqlRegularColumn) columns.get(0)).getType();
-            SqlWriter sqlWriter = new SqlPrettyWriter(factory.createSqlDialect(), false);
+            SqlWriter sqlWriter =

Review Comment:
   just replace deprecated constructorh



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/rex/RexBuilder.java:
##########
@@ -86,10 +87,6 @@
  * Factory for row expressions.
  *
  * <p>Some common literal values (NULL, TRUE, FALSE, 0, 1, '') are cached.
- *
- * <p>FLINK modifications (backport of CALCITE-6764): Lines 237, 243, 247, 251 ~ 255
- *
- * <p>FLINK modifications (backport of FLINK-39945): Lines 1270-1284

Review Comment:
   Shouldn't these comments be preserved?



##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/batch/sql/DynamicFunctionPlanTest.xml:
##########
@@ -34,10 +34,11 @@ LogicalAggregate(group=[{0, 1}], EXPR$2=[SUM($2)], EXPR$3=[COUNT()])
     </Resource>
     <Resource name="optimized exec plan">
       <![CDATA[
-HashAggregate(isMerge=[false], groupBy=[cat], auxGrouping=[gmt_date], select=[cat, gmt_date, SUM(cnt) AS EXPR$2, COUNT(*) AS EXPR$3])
-+- Exchange(distribution=[hash[cat]])
-   +- Calc(select=[cat, gmt_date, cnt], where=[(gmt_date = CURRENT_DATE())])
-      +- TableSourceScan(table=[[default_catalog, default_database, src, filter=[], project=[cat, gmt_date, cnt], metadata=[]]], fields=[cat, gmt_date, cnt])
+Calc(select=[cat, CAST(CURRENT_DATE() AS DATE) AS gmt_date, EXPR$2, EXPR$3])

Review Comment:
   This optimization is a bit fishy. Will it also be this way for streaming? For batch I guess it reduces traffic during aggregation. But for streaming it will return results that are not so easy to understand, the aggregation will happen on a different date than the one that is shown in the output.



-- 
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


Re: [PR] [FLINK-39817][table] Upgrade Calcite version to 1.39.0 [flink]

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

   @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