This is an automated email from the ASF dual-hosted git repository.

zabetak pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/master by this push:
     new d7e20ba  [CALCITE-4766] Remove unreachable code from 
SqlValidatorImpl#performUnconditionalRewrites for VALUES node (Jianhui Dong)
d7e20ba is described below

commit d7e20baf3920b9e8cd1e2171b98209ef57368216
Author: dongjianhui03 <dongjianhu...@meituan.com>
AuthorDate: Wed Sep 8 15:51:58 2021 +0800

    [CALCITE-4766] Remove unreachable code from 
SqlValidatorImpl#performUnconditionalRewrites for VALUES node (Jianhui Dong)
    
    Adapt the respective comment to reflect the current status and explain
    briefly the history (by Stamatis Zampetakis).
    
    Close apache/calcite#2511
---
 .../calcite/sql/validate/SqlValidatorImpl.java      | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java 
b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
index 6fe6207..28c0755 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
@@ -1383,20 +1383,13 @@ public class SqlValidatorImpl implements 
SqlValidatorWithHints {
     final SqlKind kind = node.getKind();
     switch (kind) {
     case VALUES:
-      // CHECKSTYLE: IGNORE 1
-      if (underFrom || true) {
-        // leave FROM (VALUES(...)) [ AS alias ] clauses alone,
-        // otherwise they grow cancerously if this rewrite is invoked
-        // over and over
-        return node;
-      } else {
-        final SqlNodeList selectList =
-            new SqlNodeList(SqlParserPos.ZERO);
-        selectList.add(SqlIdentifier.star(SqlParserPos.ZERO));
-        return new SqlSelect(node.getParserPosition(), null, selectList, node,
-            null, null, null, null, null, null, null, null);
-      }
-
+      // Do not rewrite VALUES clauses.
+      // At some point we used to rewrite VALUES(...) clauses
+      // to (SELECT * FROM VALUES(...)) but this was problematic
+      // in various cases such as FROM (VALUES(...)) [ AS alias ]
+      // where the rewrite was invoked over and over making the
+      // expression grow indefinitely.
+      return node;
     case ORDER_BY: {
       SqlOrderBy orderBy = (SqlOrderBy) node;
       handleOffsetFetch(orderBy.offset, orderBy.fetch);

Reply via email to