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

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


The following commit(s) were added to refs/heads/master by this push:
     new 580b3c0158e4 [SPARK-50636][SQL] Extending CTESubstitution.scala to 
make it aware of recursion
580b3c0158e4 is described below

commit 580b3c0158e4fd746f7c9eb9f0d63099f34f6b4c
Author: Milan Cupac <[email protected]>
AuthorDate: Fri Jan 3 19:19:20 2025 +0800

    [SPARK-50636][SQL] Extending CTESubstitution.scala to make it aware of 
recursion
    
    ### What changes were proposed in this pull request?
    
    1. Self-contained changes to CTESubstitution.scala that make CTE 
substitutions and resolutions aware of the recursion. Also, addition of error 
messages for the incorrect usage of RECURSIVE keyword
    2. Introduction of RECURSIVE keyword to the lexer and parser, and other 
additions due to the introduction of a new keyword - adding RECURSIVE to 
keywords.sql tests, and hive-thriftserver.
    
    More information about recursive CTEs and the future files to be merged: 
https://docs.google.com/document/d/1qcEJxqoXcr5cSt6HgIQjWQSqhfkSaVYkoDHsg5oxXp4/edit
    
    ### Why are the changes needed?
    
    Support for the recursive CTE.
    
    ### Does this PR introduce _any_ user-facing change?
    
    Yes. RECURSIVE keyword is introduced in this PR.
    
    ### How was this patch tested?
    
    WIP: additional tests to further test this change should be added soon
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No
    
    Closes #49232 from milanisvet/milanrcte2continue.
    
    Lead-authored-by: Milan Cupac <[email protected]>
    Co-authored-by: Nemanja Petrovic <[email protected]>
    Signed-off-by: Wenchen Fan <[email protected]>
---
 .../src/main/resources/error/error-conditions.json |  12 ++
 docs/sql-ref-ansi-compliance.md                    |   1 +
 .../spark/sql/catalyst/parser/SqlBaseLexer.g4      |   1 +
 .../spark/sql/catalyst/parser/SqlBaseParser.g4     |   3 +-
 .../sql/catalyst/analysis/CTESubstitution.scala    | 149 ++++++++++++++++-----
 ...ushdownPredicatesAndPruneColumnsForCTEDef.scala |   4 +-
 .../spark/sql/catalyst/parser/AstBuilder.scala     |   2 +-
 .../plans/logical/basicLogicalOperators.scala      |   9 +-
 .../sql-tests/analyzer-results/cte-command.sql.out |  10 +-
 .../sql-tests/analyzer-results/cte-nested.sql.out  |  98 +++++++-------
 .../analyzer-results/cte-nonlegacy.sql.out         |  54 ++++----
 .../sql-tests/analyzer-results/cte.sql.out         |  64 ++++-----
 .../double-quoted-identifiers-enabled.sql.out      |   4 +-
 .../analyzer-results/identifier-clause.sql.out     |  10 +-
 .../analyzer-results/join-lateral.sql.out          |   4 +-
 .../analyzer-results/non-excludable-rule.sql.out   |   2 +-
 .../postgreSQL/window_part3.sql.out                |   8 +-
 .../analyzer-results/postgreSQL/with.sql.out       |  12 +-
 .../analyzer-results/sql-session-variables.sql.out |   2 +-
 .../subquery/exists-subquery/exists-cte.sql.out    |  14 +-
 .../in-subquery/in-multiple-columns.sql.out        |   2 +-
 .../subquery/in-subquery/in-with-cte.sql.out       |  20 +--
 .../scalar-subquery/scalar-subquery-select.sql.out |  18 +--
 .../sql-tests/analyzer-results/transform.sql.out   |   2 +-
 .../sql-tests/analyzer-results/using-join.sql.out  |   4 +-
 .../sql-tests/results/keywords-enforced.sql.out    |   2 +
 .../resources/sql-tests/results/keywords.sql.out   |   1 +
 .../sql-tests/results/nonansi/keywords.sql.out     |   1 +
 .../ThriftServerWithSparkContextSuite.scala        |   2 +-
 29 files changed, 311 insertions(+), 204 deletions(-)

diff --git a/common/utils/src/main/resources/error/error-conditions.json 
b/common/utils/src/main/resources/error/error-conditions.json
index 733b094f744e..573e7f3a6a38 100644
--- a/common/utils/src/main/resources/error/error-conditions.json
+++ b/common/utils/src/main/resources/error/error-conditions.json
@@ -4146,6 +4146,18 @@
     ],
     "sqlState" : "38000"
   },
+  "RECURSIVE_CTE_IN_LEGACY_MODE" : {
+    "message" : [
+      "Recursive definitions cannot be used in legacy CTE precedence mode 
(spark.sql.legacy.ctePrecedencePolicy=LEGACY)."
+    ],
+    "sqlState" : "42836"
+  },
+  "RECURSIVE_CTE_WHEN_INLINING_IS_FORCED" : {
+    "message" : [
+      "Recursive definitions cannot be used when CTE inlining is forced."
+    ],
+    "sqlState" : "42836"
+  },
   "RECURSIVE_PROTOBUF_SCHEMA" : {
     "message" : [
       "Found recursive reference in Protobuf schema, which can not be 
processed by Spark by default: <fieldDescriptor>. try setting the option 
`recursive.fields.max.depth` 1 to 10. Going beyond 10 levels of recursion is 
not allowed."
diff --git a/docs/sql-ref-ansi-compliance.md b/docs/sql-ref-ansi-compliance.md
index 7af54850f5da..50cdcd6d0979 100644
--- a/docs/sql-ref-ansi-compliance.md
+++ b/docs/sql-ref-ansi-compliance.md
@@ -651,6 +651,7 @@ Below is a list of all the keywords in Spark SQL.
 |RECORDREADER|non-reserved|non-reserved|non-reserved|
 |RECORDWRITER|non-reserved|non-reserved|non-reserved|
 |RECOVER|non-reserved|non-reserved|non-reserved|
+|RECURSIVE|reserved|non-reserved|reserved|
 |REDUCE|non-reserved|non-reserved|non-reserved|
 |REFERENCES|reserved|non-reserved|reserved|
 |REFRESH|non-reserved|non-reserved|non-reserved|
diff --git 
a/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseLexer.g4 
b/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseLexer.g4
index eeebe89de8ff..91a267364216 100644
--- 
a/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseLexer.g4
+++ 
b/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseLexer.g4
@@ -365,6 +365,7 @@ REAL: 'REAL';
 RECORDREADER: 'RECORDREADER';
 RECORDWRITER: 'RECORDWRITER';
 RECOVER: 'RECOVER';
+RECURSIVE: 'RECURSIVE';
 REDUCE: 'REDUCE';
 REFERENCES: 'REFERENCES';
 REFRESH: 'REFRESH';
diff --git 
a/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4 
b/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4
index a5d217486bf2..3ca120da98dd 100644
--- 
a/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4
+++ 
b/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4
@@ -509,7 +509,7 @@ describeColName
     ;
 
 ctes
-    : WITH namedQuery (COMMA namedQuery)*
+    : WITH RECURSIVE? namedQuery (COMMA namedQuery)*
     ;
 
 namedQuery
@@ -2118,6 +2118,7 @@ nonReserved
     | RECORDREADER
     | RECORDWRITER
     | RECOVER
+    | RECURSIVE
     | REDUCE
     | REFERENCES
     | REFRESH
diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CTESubstitution.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CTESubstitution.scala
index 84f6d04eeb1a..50f149bb2806 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CTESubstitution.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CTESubstitution.scala
@@ -149,10 +149,15 @@ object CTESubstitution extends Rule[LogicalPlan] {
       plan: LogicalPlan,
       cteDefs: ArrayBuffer[CTERelationDef]): LogicalPlan = {
     plan.resolveOperatorsUp {
-      case UnresolvedWith(child, relations, _) =>
-        val resolvedCTERelations =
-          resolveCTERelations(relations, isLegacy = true, forceInline = false, 
Seq.empty, cteDefs)
-        substituteCTE(child, alwaysInline = true, resolvedCTERelations)
+      case cte @ UnresolvedWith(child, relations, allowRecursion) =>
+        if (allowRecursion) {
+          cte.failAnalysis(
+            errorClass = "RECURSIVE_CTE_IN_LEGACY_MODE",
+            messageParameters = Map.empty)
+        }
+        val resolvedCTERelations = resolveCTERelations(relations, isLegacy = 
true,
+          forceInline = false, Seq.empty, cteDefs, allowRecursion)
+        substituteCTE(child, alwaysInline = true, resolvedCTERelations, None)
     }
   }
 
@@ -202,14 +207,21 @@ object CTESubstitution extends Rule[LogicalPlan] {
     var firstSubstituted: Option[LogicalPlan] = None
     val newPlan = plan.resolveOperatorsDownWithPruning(
         _.containsAnyPattern(UNRESOLVED_WITH, PLAN_EXPRESSION)) {
-      case UnresolvedWith(child: LogicalPlan, relations, _) =>
+      // allowRecursion flag is set to `True` by the parser if the `RECURSIVE` 
keyword is used.
+      case cte @ UnresolvedWith(child: LogicalPlan, relations, allowRecursion) 
=>
+        if (allowRecursion && forceInline) {
+          cte.failAnalysis(
+            errorClass = "RECURSIVE_CTE_WHEN_INLINING_IS_FORCED",
+            messageParameters = Map.empty)
+        }
         val resolvedCTERelations =
-          resolveCTERelations(relations, isLegacy = false, forceInline, 
outerCTEDefs, cteDefs) ++
-            outerCTEDefs
+          resolveCTERelations(relations, isLegacy = false, forceInline, 
outerCTEDefs, cteDefs,
+            allowRecursion) ++ outerCTEDefs
         val substituted = substituteCTE(
           traverseAndSubstituteCTE(child, forceInline, resolvedCTERelations, 
cteDefs)._1,
           forceInline,
-          resolvedCTERelations)
+          resolvedCTERelations,
+          None)
         if (firstSubstituted.isEmpty) {
           firstSubstituted = Some(substituted)
         }
@@ -228,7 +240,8 @@ object CTESubstitution extends Rule[LogicalPlan] {
       isLegacy: Boolean,
       forceInline: Boolean,
       outerCTEDefs: Seq[(String, CTERelationDef)],
-      cteDefs: ArrayBuffer[CTERelationDef]): Seq[(String, CTERelationDef)] = {
+      cteDefs: ArrayBuffer[CTERelationDef],
+      allowRecursion: Boolean): Seq[(String, CTERelationDef)] = {
     val alwaysInline = isLegacy || forceInline
     var resolvedCTERelations = if (alwaysInline) {
       Seq.empty
@@ -247,49 +260,116 @@ object CTESubstitution extends Rule[LogicalPlan] {
         // NOTE: we must call `traverseAndSubstituteCTE` before 
`substituteCTE`, as the relations
         // in the inner CTE have higher priority over the relations in the 
outer CTE when resolving
         // inner CTE relations. For example:
-        // WITH t1 AS (SELECT 1)
-        // t2 AS (
-        //   WITH t1 AS (SELECT 2)
-        //   WITH t3 AS (SELECT * FROM t1)
-        // )
-        // t3 should resolve the t1 to `SELECT 2` instead of `SELECT 1`.
-        traverseAndSubstituteCTE(relation, forceInline, resolvedCTERelations, 
cteDefs)._1
+        // WITH
+        //   t1 AS (SELECT 1),
+        //   t2 AS (
+        //     WITH
+        //       t1 AS (SELECT 2),
+        //       t3 AS (SELECT * FROM t1)
+        //     SELECT * FROM t1
+        //   )
+        // SELECT * FROM t2
+        // t3 should resolve the t1 to `SELECT 2` ("inner" t1) instead of 
`SELECT 1`.
+        //
+        // When recursion allowed (RECURSIVE keyword used):
+        // Consider following example:
+        //  WITH
+        //    t1 AS (SELECT 1),
+        //    t2 AS (
+        //      WITH RECURSIVE
+        //        t1 AS (
+        //          SELECT 1 AS level
+        //          UNION (
+        //            WITH t3 AS (SELECT level + 1 FROM t1 WHERE level < 10)
+        //            SELECT * FROM t3
+        //          )
+        //        )
+        //      SELECT * FROM t1
+        //    )
+        //  SELECT * FROM t2
+        // t1 reference within t3 would initially resolve to outer `t1` 
(SELECT 1), as the inner t1
+        // is not yet known. Therefore, we need to remove definitions that 
conflict with current
+        // relation `name` from the list of `outerCTEDefs` entering 
`traverseAndSubstituteCTE()`.
+        // NOTE: It will be recognized later in the code that this is actually 
a self-reference
+        // (reference to the inner t1).
+        val nonConflictingCTERelations = if (allowRecursion) {
+          resolvedCTERelations.filterNot {
+            case (cteName, cteDef) => cteDef.conf.resolver(cteName, name)
+          }
+        } else {
+          resolvedCTERelations
+        }
+        traverseAndSubstituteCTE(relation, forceInline, 
nonConflictingCTERelations, cteDefs)._1
       }
-      // CTE definition can reference a previous one
-      val substituted = substituteCTE(innerCTEResolved, alwaysInline, 
resolvedCTERelations)
+
+      // If recursion is allowed (RECURSIVE keyword specified)
+      // then it has higher priority than outer or previous relations.
+      // Therefore, we construct a `CTERelationDef` for the current relation.
+      // Later if we encounter unresolved relation which we need to find which 
CTE Def it is
+      // referencing to, we first check if it is a reference to this one. If 
yes, then we set the
+      // reference as being recursive.
+      val recursiveCTERelation = if (allowRecursion) {
+        Some(name -> CTERelationDef(relation))
+      } else {
+        None
+      }
+      // CTE definition can reference a previous one or itself if recursion 
allowed.
+      val substituted = substituteCTE(innerCTEResolved, alwaysInline,
+        resolvedCTERelations, recursiveCTERelation)
       val cteRelation = CTERelationDef(substituted)
       if (!alwaysInline) {
         cteDefs += cteRelation
       }
+
       // Prepending new CTEs makes sure that those have higher priority over 
outer ones.
       resolvedCTERelations +:= (name -> cteRelation)
     }
     resolvedCTERelations
   }
 
+  /**
+   * This function is called from `substituteCTE` to actually substitute 
unresolved relations
+   * with CTE references.
+   */
   private def resolveWithCTERelations(
       table: String,
       alwaysInline: Boolean,
       cteRelations: Seq[(String, CTERelationDef)],
+      recursiveCTERelation: Option[(String, CTERelationDef)],
       unresolvedRelation: UnresolvedRelation): LogicalPlan = {
-    cteRelations
-      .find(r => conf.resolver(r._1, table))
-      .map {
+    if (recursiveCTERelation.isDefined && 
conf.resolver(recursiveCTERelation.get._1, table)) {
+      // self-reference is found
+      recursiveCTERelation.map {
         case (_, d) =>
-          if (alwaysInline) {
-            d.child
-          } else {
-            // Add a `SubqueryAlias` for hint-resolving rules to match 
relation names.
-            SubqueryAlias(table, CTERelationRef(d.id, d.resolved, d.output, 
d.isStreaming))
-          }
-      }
-      .getOrElse(unresolvedRelation)
+          SubqueryAlias(table,
+            CTERelationRef(d.id, d.resolved, d.output, d.isStreaming, 
recursive = true))
+      }.get
+    } else {
+      cteRelations
+        .find(r => conf.resolver(r._1, table))
+        .map {
+          case (_, d) =>
+            if (alwaysInline) {
+              d.child
+            } else {
+              // Add a `SubqueryAlias` for hint-resolving rules to match 
relation names.
+              // This is a non-recursive reference, recursive parameter is by 
default set to false
+              SubqueryAlias(table,
+                CTERelationRef(d.id, d.resolved, d.output, d.isStreaming))
+            }
+        }
+        .getOrElse(unresolvedRelation)
+    }
   }
 
+  /**
+   * Substitute unresolved relations in the plan with CTE references 
(CTERelationRef).
+   */
   private def substituteCTE(
       plan: LogicalPlan,
       alwaysInline: Boolean,
-      cteRelations: Seq[(String, CTERelationDef)]): LogicalPlan = {
+      cteRelations: Seq[(String, CTERelationDef)],
+      recursiveCTERelation: Option[(String, CTERelationDef)]): LogicalPlan = {
     plan.resolveOperatorsUpWithPruning(
         _.containsAnyPattern(RELATION_TIME_TRAVEL, UNRESOLVED_RELATION, 
PLAN_EXPRESSION,
           UNRESOLVED_IDENTIFIER)) {
@@ -298,7 +378,8 @@ object CTESubstitution extends Rule[LogicalPlan] {
         throw QueryCompilationErrors.timeTravelUnsupportedError(toSQLId(table))
 
       case u @ UnresolvedRelation(Seq(table), _, _) =>
-        resolveWithCTERelations(table, alwaysInline, cteRelations, u)
+        resolveWithCTERelations(table, alwaysInline, cteRelations,
+          recursiveCTERelation, u)
 
       case p: PlanWithUnresolvedIdentifier =>
         // We must look up CTE relations first when resolving 
`UnresolvedRelation`s,
@@ -308,7 +389,8 @@ object CTESubstitution extends Rule[LogicalPlan] {
         p.copy(planBuilder = (nameParts, children) => {
           p.planBuilder.apply(nameParts, children) match {
             case u @ UnresolvedRelation(Seq(table), _, _) =>
-              resolveWithCTERelations(table, alwaysInline, cteRelations, u)
+              resolveWithCTERelations(table, alwaysInline, cteRelations,
+                recursiveCTERelation, u)
             case other => other
           }
         })
@@ -317,7 +399,8 @@ object CTESubstitution extends Rule[LogicalPlan] {
         // This cannot be done in ResolveSubquery because ResolveSubquery does 
not know the CTE.
         
other.transformExpressionsWithPruning(_.containsPattern(PLAN_EXPRESSION)) {
           case e: SubqueryExpression =>
-            e.withNewPlan(apply(substituteCTE(e.plan, alwaysInline, 
cteRelations)))
+            e.withNewPlan(
+              apply(substituteCTE(e.plan, alwaysInline, cteRelations, None)))
         }
     }
   }
diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/PushdownPredicatesAndPruneColumnsForCTEDef.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/PushdownPredicatesAndPruneColumnsForCTEDef.scala
index 838827a0e2e1..59b3d83c5516 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/PushdownPredicatesAndPruneColumnsForCTEDef.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/PushdownPredicatesAndPruneColumnsForCTEDef.scala
@@ -122,7 +122,7 @@ object PushdownPredicatesAndPruneColumnsForCTEDef extends 
Rule[LogicalPlan] {
   private def pushdownPredicatesAndAttributes(
       plan: LogicalPlan,
       cteMap: CTEMap): LogicalPlan = plan.transformWithSubqueries {
-    case cteDef @ CTERelationDef(child, id, originalPlanWithPredicates, _, _, 
_) =>
+    case cteDef @ CTERelationDef(child, id, originalPlanWithPredicates, _, _) 
=>
       val (_, _, newPreds, newAttrSet) = cteMap(id)
       val originalPlan = originalPlanWithPredicates.map(_._1).getOrElse(child)
       val preds = originalPlanWithPredicates.map(_._2).getOrElse(Seq.empty)
@@ -170,7 +170,7 @@ object PushdownPredicatesAndPruneColumnsForCTEDef extends 
Rule[LogicalPlan] {
 object CleanUpTempCTEInfo extends Rule[LogicalPlan] {
   override def apply(plan: LogicalPlan): LogicalPlan =
     plan.transformWithPruning(_.containsPattern(CTE)) {
-      case cteDef @ CTERelationDef(_, _, Some(_), _, _, _) =>
+      case cteDef @ CTERelationDef(_, _, Some(_), _, _) =>
         cteDef.copy(originalPlanWithPredicates = None)
     }
 }
diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
index aa32cc910051..0a300cea03ff 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
@@ -551,7 +551,7 @@ class AstBuilder extends DataTypeAstBuilder
       throw QueryParsingErrors.duplicateCteDefinitionNamesError(
         duplicates.map(toSQLId).mkString(", "), ctx)
     }
-    UnresolvedWith(plan, ctes.toSeq)
+    UnresolvedWith(plan, ctes.toSeq, ctx.RECURSIVE() != null)
   }
 
   /**
diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala
index b897026a0df4..c1261f2b5fac 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala
@@ -866,7 +866,6 @@ case class UnresolvedWith(
  *                                   pushdown to help ensure rule idempotency.
  * @param underSubquery If true, it means we don't need to add a shuffle for 
this CTE relation as
  *                      subquery reuse will be applied to reuse CTE relation 
output.
- * @param recursive If true, then this CTE Definition is recursive - it 
contains a self-reference.
  * @param recursionAnchor A helper plan node that temporary stores the anchor 
term of recursive
  *                        definitions. In the beginning of recursive 
resolution the `ResolveWithCTE`
  *                        rule updates this parameter and once it is resolved 
the same rule resolves
@@ -877,7 +876,6 @@ case class CTERelationDef(
     id: Long = CTERelationDef.newId,
     originalPlanWithPredicates: Option[(LogicalPlan, Seq[Expression])] = None,
     underSubquery: Boolean = false,
-    recursive: Boolean = false,
     recursionAnchor: Option[LogicalPlan] = None) extends UnaryNode {
 
   final override val nodePatterns: Seq[TreePattern] = Seq(CTE)
@@ -886,6 +884,13 @@ case class CTERelationDef(
     copy(child = newChild)
 
   override def output: Seq[Attribute] = if (resolved) child.output else Nil
+
+  lazy val recursive: Boolean = child.exists{
+    // if the reference is found inside the child, referencing to this CTE 
definition,
+    // and already marked as recursive, then this CTE definition is recursive.
+    case CTERelationRef(this.id, _, _, _, _, true) => true
+    case _ => false
+  }
 }
 
 object CTERelationDef {
diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/cte-command.sql.out 
b/sql/core/src/test/resources/sql-tests/analyzer-results/cte-command.sql.out
index 926e3cd00304..c12076b85b1d 100644
--- a/sql/core/src/test/resources/sql-tests/analyzer-results/cte-command.sql.out
+++ b/sql/core/src/test/resources/sql-tests/analyzer-results/cte-command.sql.out
@@ -4,7 +4,7 @@ CREATE TABLE cte_tbl USING csv AS WITH s AS (SELECT 42 AS col) 
SELECT * FROM s
 -- !query analysis
 CreateDataSourceTableAsSelectCommand `spark_catalog`.`default`.`cte_tbl`, 
ErrorIfExists, [col]
    +- WithCTE
-      :- CTERelationDef xxxx, false, false
+      :- CTERelationDef xxxx, false
       :  +- SubqueryAlias s
       :     +- Project [42 AS col#x]
       :        +- OneRowRelation
@@ -26,7 +26,7 @@ CREATE TEMPORARY VIEW cte_view AS WITH s AS (SELECT 42 AS 
col) SELECT * FROM s
 -- !query analysis
 CreateViewCommand `cte_view`, WITH s AS (SELECT 42 AS col) SELECT * FROM s, 
false, false, LocalTempView, UNSUPPORTED, true
    +- WithCTE
-      :- CTERelationDef xxxx, false, false
+      :- CTERelationDef xxxx, false
       :  +- SubqueryAlias s
       :     +- Project [42 AS col#x]
       :        +- OneRowRelation
@@ -43,7 +43,7 @@ Project [col#x]
    +- View (`cte_view`, [col#x])
       +- Project [cast(col#x as int) AS col#x]
          +- WithCTE
-            :- CTERelationDef xxxx, false, false
+            :- CTERelationDef xxxx, false
             :  +- SubqueryAlias s
             :     +- Project [42 AS col#x]
             :        +- OneRowRelation
@@ -58,7 +58,7 @@ INSERT INTO cte_tbl SELECT * FROM S
 -- !query analysis
 InsertIntoHadoopFsRelationCommand file:[not included in 
comparison]/{warehouse_dir}/cte_tbl, false, CSV, [path=file:[not included in 
comparison]/{warehouse_dir}/cte_tbl], Append, 
`spark_catalog`.`default`.`cte_tbl`, 
org.apache.spark.sql.execution.datasources.InMemoryFileIndex(file:[not included 
in comparison]/{warehouse_dir}/cte_tbl), [col]
 +- WithCTE
-   :- CTERelationDef xxxx, false, false
+   :- CTERelationDef xxxx, false
    :  +- SubqueryAlias s
    :     +- Project [43 AS col#x]
    :        +- OneRowRelation
@@ -80,7 +80,7 @@ INSERT INTO cte_tbl WITH s AS (SELECT 44 AS col) SELECT * 
FROM s
 -- !query analysis
 InsertIntoHadoopFsRelationCommand file:[not included in 
comparison]/{warehouse_dir}/cte_tbl, false, CSV, [path=file:[not included in 
comparison]/{warehouse_dir}/cte_tbl], Append, 
`spark_catalog`.`default`.`cte_tbl`, 
org.apache.spark.sql.execution.datasources.InMemoryFileIndex(file:[not included 
in comparison]/{warehouse_dir}/cte_tbl), [col]
 +- WithCTE
-   :- CTERelationDef xxxx, false, false
+   :- CTERelationDef xxxx, false
    :  +- SubqueryAlias s
    :     +- Project [44 AS col#x]
    :        +- OneRowRelation
diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/cte-nested.sql.out 
b/sql/core/src/test/resources/sql-tests/analyzer-results/cte-nested.sql.out
index 0365c4dcd8e0..1b968d0431f4 100644
--- a/sql/core/src/test/resources/sql-tests/analyzer-results/cte-nested.sql.out
+++ b/sql/core/src/test/resources/sql-tests/analyzer-results/cte-nested.sql.out
@@ -7,11 +7,11 @@ WITH t as (
 SELECT * FROM t
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t2
 :     +- Project [1 AS 1#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1#x]
 :        +- SubqueryAlias t2
@@ -30,7 +30,7 @@ SELECT max(c) FROM (
 Aggregate [max(c#x) AS max(c)#x]
 +- SubqueryAlias __auto_generated_subquery_name
    +- WithCTE
-      :- CTERelationDef xxxx, false, false
+      :- CTERelationDef xxxx, false
       :  +- SubqueryAlias t
       :     +- Project [1#x AS c#x]
       :        +- Project [1 AS 1#x]
@@ -48,7 +48,7 @@ SELECT (
 -- !query analysis
 Project [scalar-subquery#x [] AS scalarsubquery()#x]
 :  +- WithCTE
-:     :- CTERelationDef xxxx, false, false
+:     :- CTERelationDef xxxx, false
 :     :  +- SubqueryAlias t
 :     :     +- Project [1 AS 1#x]
 :     :        +- OneRowRelation
@@ -66,7 +66,7 @@ SELECT (
 -- !query analysis
 Project [scalar-subquery#x [id#xL] AS scalarsubquery(id)#x]
 :  +- WithCTE
-:     :- CTERelationDef xxxx, false, false
+:     :- CTERelationDef xxxx, false
 :     :  +- SubqueryAlias unreferenced
 :     :     +- Project [outer(id#xL)]
 :     :        +- OneRowRelation
@@ -83,7 +83,7 @@ SELECT (
 -- !query analysis
 Project [scalar-subquery#x [id#xL] AS scalarsubquery(id)#xL]
 :  +- WithCTE
-:     :- CTERelationDef xxxx, false, false
+:     :- CTERelationDef xxxx, false
 :     :  +- SubqueryAlias unreferenced
 :     :     +- Project [1 AS 1#x]
 :     :        +- OneRowRelation
@@ -128,15 +128,15 @@ WITH
 SELECT * FROM t2
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1 AS 1#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [2 AS 2#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t2
 :     +- Project [2#x]
 :        +- SubqueryAlias t
@@ -160,18 +160,18 @@ WITH
 SELECT * FROM t2
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1#x AS c#x]
 :        +- Project [1 AS 1#x]
 :           +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t2
 :     +- Project [scalar-subquery#x [] AS scalarsubquery()#x]
 :        :  +- Aggregate [max(c#x) AS max(c)#x]
 :        :     +- SubqueryAlias __auto_generated_subquery_name
 :        :        +- WithCTE
-:        :           :- CTERelationDef xxxx, false, false
+:        :           :- CTERelationDef xxxx, false
 :        :           :  +- SubqueryAlias t
 :        :           :     +- Project [2#x AS c#x]
 :        :           :        +- Project [2 AS 2#x]
@@ -199,24 +199,24 @@ WITH
 SELECT * FROM t2
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1 AS 1#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [2 AS 2#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [3 AS 3#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t2
 :     +- Project [3#x]
 :        +- SubqueryAlias t
 :           +- CTERelationRef xxxx, true, [3#x], false, false
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t2
 :     +- Project [3#x]
 :        +- SubqueryAlias t2
@@ -234,12 +234,12 @@ SELECT max(c) FROM (
 )
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1#x AS c#x]
 :        +- Project [1 AS 1#x]
 :           +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [2#x AS c#x]
 :        +- Project [2 AS 2#x]
@@ -261,12 +261,12 @@ SELECT sum(c) FROM (
 )
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1#x AS c#x]
 :        +- Project [1 AS 1#x]
 :           +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [2#x AS c#x]
 :        +- Project [2 AS 2#x]
@@ -291,17 +291,17 @@ SELECT sum(c) FROM (
 )
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1#x AS c#x]
 :        +- Project [1 AS 1#x]
 :           +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [2#x AS c#x]
 :        +- Project [2 AS 2#x]
 :           +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [3#x AS c#x]
 :        +- Project [3 AS 3#x]
@@ -323,13 +323,13 @@ SELECT (
 )
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1 AS 1#x]
 :        +- OneRowRelation
 +- Project [scalar-subquery#x [] AS scalarsubquery()#x]
    :  +- WithCTE
-   :     :- CTERelationDef xxxx, false, false
+   :     :- CTERelationDef xxxx, false
    :     :  +- SubqueryAlias t
    :     :     +- Project [2 AS 2#x]
    :     :        +- OneRowRelation
@@ -349,14 +349,14 @@ SELECT (
 )
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1 AS 1#x]
 :        +- OneRowRelation
 +- Project [scalar-subquery#x [] AS scalarsubquery()#x]
    :  +- Project [scalar-subquery#x [] AS scalarsubquery()#x]
    :     :  +- WithCTE
-   :     :     :- CTERelationDef xxxx, false, false
+   :     :     :- CTERelationDef xxxx, false
    :     :     :  +- SubqueryAlias t
    :     :     :     +- Project [2 AS 2#x]
    :     :     :        +- OneRowRelation
@@ -378,19 +378,19 @@ SELECT (
 )
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1 AS 1#x]
 :        +- OneRowRelation
 +- Project [scalar-subquery#x [] AS scalarsubquery()#x]
    :  +- WithCTE
-   :     :- CTERelationDef xxxx, false, false
+   :     :- CTERelationDef xxxx, false
    :     :  +- SubqueryAlias t
    :     :     +- Project [2 AS 2#x]
    :     :        +- OneRowRelation
    :     +- Project [scalar-subquery#x [] AS scalarsubquery()#x]
    :        :  +- WithCTE
-   :        :     :- CTERelationDef xxxx, false, false
+   :        :     :- CTERelationDef xxxx, false
    :        :     :  +- SubqueryAlias t
    :        :     :     +- Project [3 AS 3#x]
    :        :     :        +- OneRowRelation
@@ -410,7 +410,7 @@ WHERE c IN (
 )
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1#x AS c#x]
 :        +- Project [1 AS 1#x]
@@ -418,7 +418,7 @@ WithCTE
 +- Project [c#x]
    +- Filter c#x IN (list#x [])
       :  +- WithCTE
-      :     :- CTERelationDef xxxx, false, false
+      :     :- CTERelationDef xxxx, false
       :     :  +- SubqueryAlias t
       :     :     +- Project [2#x AS c#x]
       :     :        +- Project [2 AS 2#x]
@@ -440,16 +440,16 @@ WITH
 SELECT * FROM t
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t2
 :     +- Project [1 AS 1#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1#x]
 :        +- SubqueryAlias t2
 :           +- CTERelationRef xxxx, true, [1#x], false, false
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t2
 :     +- Project [2 AS 2#x]
 :        +- OneRowRelation
@@ -468,15 +468,15 @@ WITH
 SELECT * FROM t
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias abc
 :     +- Project [1 AS 1#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias aBc
 :     +- Project [2 AS 2#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [2#x]
 :        +- SubqueryAlias aBC
@@ -494,13 +494,13 @@ SELECT (
 )
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias abc
 :     +- Project [1 AS 1#x]
 :        +- OneRowRelation
 +- Project [scalar-subquery#x [] AS scalarsubquery()#x]
    :  +- WithCTE
-   :     :- CTERelationDef xxxx, false, false
+   :     :- CTERelationDef xxxx, false
    :     :  +- SubqueryAlias aBc
    :     :     +- Project [2 AS 2#x]
    :     :        +- OneRowRelation
@@ -522,16 +522,16 @@ WITH
 SELECT * FROM t2
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t1
 :     +- Project [1 AS 1#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t3
 :     +- Project [1#x]
 :        +- SubqueryAlias t1
 :           +- CTERelationRef xxxx, true, [1#x], false, false
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t2
 :     +- Project [1#x]
 :        +- SubqueryAlias t3
@@ -553,11 +553,11 @@ SELECT * FROM (
 )
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte_outer
 :     +- Project [1 AS 1#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte_inner
 :     +- Project [1#x]
 :        +- SubqueryAlias cte_outer
@@ -586,16 +586,16 @@ SELECT * FROM (
 )
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte_outer
 :     +- Project [1 AS 1#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte_inner_inner
 :     +- Project [1#x]
 :        +- SubqueryAlias cte_outer
 :           +- CTERelationRef xxxx, true, [1#x], false, false
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte_inner
 :     +- Project [1#x]
 :        +- SubqueryAlias __auto_generated_subquery_name
diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/cte-nonlegacy.sql.out 
b/sql/core/src/test/resources/sql-tests/analyzer-results/cte-nonlegacy.sql.out
index 53dcd46361dc..fcfe64097069 100644
--- 
a/sql/core/src/test/resources/sql-tests/analyzer-results/cte-nonlegacy.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/analyzer-results/cte-nonlegacy.sql.out
@@ -7,11 +7,11 @@ WITH t as (
 SELECT * FROM t
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t2
 :     +- Project [1 AS 1#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1#x]
 :        +- SubqueryAlias t2
@@ -30,7 +30,7 @@ SELECT max(c) FROM (
 Aggregate [max(c#x) AS max(c)#x]
 +- SubqueryAlias __auto_generated_subquery_name
    +- WithCTE
-      :- CTERelationDef xxxx, false, false
+      :- CTERelationDef xxxx, false
       :  +- SubqueryAlias t
       :     +- Project [1#x AS c#x]
       :        +- Project [1 AS 1#x]
@@ -48,7 +48,7 @@ SELECT (
 -- !query analysis
 Project [scalar-subquery#x [] AS scalarsubquery()#x]
 :  +- WithCTE
-:     :- CTERelationDef xxxx, false, false
+:     :- CTERelationDef xxxx, false
 :     :  +- SubqueryAlias t
 :     :     +- Project [1 AS 1#x]
 :     :        +- OneRowRelation
@@ -66,7 +66,7 @@ SELECT (
 -- !query analysis
 Project [scalar-subquery#x [id#xL] AS scalarsubquery(id)#x]
 :  +- WithCTE
-:     :- CTERelationDef xxxx, false, false
+:     :- CTERelationDef xxxx, false
 :     :  +- SubqueryAlias unreferenced
 :     :     +- Project [outer(id#xL)]
 :     :        +- OneRowRelation
@@ -83,7 +83,7 @@ SELECT (
 -- !query analysis
 Project [scalar-subquery#x [id#xL] AS scalarsubquery(id)#xL]
 :  +- WithCTE
-:     :- CTERelationDef xxxx, false, false
+:     :- CTERelationDef xxxx, false
 :     :  +- SubqueryAlias unreferenced
 :     :     +- Project [1 AS 1#x]
 :     :        +- OneRowRelation
@@ -153,18 +153,18 @@ WITH
 SELECT * FROM t2
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1#x AS c#x]
 :        +- Project [1 AS 1#x]
 :           +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t2
 :     +- Project [scalar-subquery#x [] AS scalarsubquery()#x]
 :        :  +- Aggregate [max(c#x) AS max(c)#x]
 :        :     +- SubqueryAlias __auto_generated_subquery_name
 :        :        +- WithCTE
-:        :           :- CTERelationDef xxxx, false, false
+:        :           :- CTERelationDef xxxx, false
 :        :           :  +- SubqueryAlias t
 :        :           :     +- Project [2#x AS c#x]
 :        :           :        +- Project [2 AS 2#x]
@@ -211,12 +211,12 @@ SELECT max(c) FROM (
 )
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1#x AS c#x]
 :        +- Project [1 AS 1#x]
 :           +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [2#x AS c#x]
 :        +- Project [2 AS 2#x]
@@ -238,12 +238,12 @@ SELECT sum(c) FROM (
 )
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1#x AS c#x]
 :        +- Project [1 AS 1#x]
 :           +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [2#x AS c#x]
 :        +- Project [2 AS 2#x]
@@ -268,17 +268,17 @@ SELECT sum(c) FROM (
 )
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1#x AS c#x]
 :        +- Project [1 AS 1#x]
 :           +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [2#x AS c#x]
 :        +- Project [2 AS 2#x]
 :           +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [3#x AS c#x]
 :        +- Project [3 AS 3#x]
@@ -384,16 +384,16 @@ WITH
 SELECT * FROM t
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t2
 :     +- Project [1 AS 1#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1#x]
 :        +- SubqueryAlias t2
 :           +- CTERelationRef xxxx, true, [1#x], false, false
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t2
 :     +- Project [2 AS 2#x]
 :        +- OneRowRelation
@@ -454,16 +454,16 @@ WITH
 SELECT * FROM t2
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t1
 :     +- Project [1 AS 1#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t3
 :     +- Project [1#x]
 :        +- SubqueryAlias t1
 :           +- CTERelationRef xxxx, true, [1#x], false, false
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t2
 :     +- Project [1#x]
 :        +- SubqueryAlias t3
@@ -485,11 +485,11 @@ SELECT * FROM (
 )
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte_outer
 :     +- Project [1 AS 1#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte_inner
 :     +- Project [1#x]
 :        +- SubqueryAlias cte_outer
@@ -518,16 +518,16 @@ SELECT * FROM (
 )
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte_outer
 :     +- Project [1 AS 1#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte_inner_inner
 :     +- Project [1#x]
 :        +- SubqueryAlias cte_outer
 :           +- CTERelationRef xxxx, true, [1#x], false, false
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte_inner
 :     +- Project [1#x]
 :        +- SubqueryAlias __auto_generated_subquery_name
diff --git a/sql/core/src/test/resources/sql-tests/analyzer-results/cte.sql.out 
b/sql/core/src/test/resources/sql-tests/analyzer-results/cte.sql.out
index 9a221f6a699c..ea09573db51a 100644
--- a/sql/core/src/test/resources/sql-tests/analyzer-results/cte.sql.out
+++ b/sql/core/src/test/resources/sql-tests/analyzer-results/cte.sql.out
@@ -62,7 +62,7 @@ org.apache.spark.sql.catalyst.ExtendedAnalysisException
 WITH t AS (SELECT 1 FROM t) SELECT * FROM t
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1 AS 1#x]
 :        +- SubqueryAlias t
@@ -100,7 +100,7 @@ org.apache.spark.sql.catalyst.ExtendedAnalysisException
 WITH t1 AS (SELECT * FROM t2), t2 AS (SELECT 2 FROM t1) SELECT * FROM t1 cross 
join t2
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t1
 :     +- Project [id#x]
 :        +- SubqueryAlias t2
@@ -109,7 +109,7 @@ WithCTE
 :                 +- Project [id#x]
 :                    +- SubqueryAlias t
 :                       +- LocalRelation [id#x]
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t2
 :     +- Project [2 AS 2#x]
 :        +- SubqueryAlias t1
@@ -134,7 +134,7 @@ FROM   CTE1 t1
        CROSS JOIN CTE1 t2
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias CTE1
 :     +- Project [id#x AS id#x]
 :        +- Join Cross
@@ -168,7 +168,7 @@ WITH t(x) AS (SELECT 1)
 SELECT * FROM t WHERE x = 1
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1#x AS x#x]
 :        +- Project [1 AS 1#x]
@@ -184,7 +184,7 @@ WITH t(x, y) AS (SELECT 1, 2)
 SELECT * FROM t WHERE x = 1 AND y = 2
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1#x AS x#x, 2#x AS y#x]
 :        +- Project [1 AS 1#x, 2 AS 2#x]
@@ -200,7 +200,7 @@ WITH t(x, x) AS (SELECT 1, 2)
 SELECT * FROM t
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1#x AS x#x, 2#x AS x#x]
 :        +- Project [1 AS 1#x, 2 AS 2#x]
@@ -300,48 +300,48 @@ WITH w1(c1) AS
 SELECT * FROM w1
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias w8
 :     +- Project [1#x AS c8#x]
 :        +- Project [1 AS 1#x]
 :           +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias w7
 :     +- Project [c8#x AS c7#x]
 :        +- Project [c8#x]
 :           +- SubqueryAlias w8
 :              +- CTERelationRef xxxx, true, [c8#x], false, false
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias w6
 :     +- Project [c7#x AS c6#x]
 :        +- Project [c7#x]
 :           +- SubqueryAlias w7
 :              +- CTERelationRef xxxx, true, [c7#x], false, false
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias w5
 :     +- Project [c6#x AS c5#x]
 :        +- Project [c6#x]
 :           +- SubqueryAlias w6
 :              +- CTERelationRef xxxx, true, [c6#x], false, false
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias w4
 :     +- Project [c5#x AS c4#x]
 :        +- Project [c5#x]
 :           +- SubqueryAlias w5
 :              +- CTERelationRef xxxx, true, [c5#x], false, false
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias w3
 :     +- Project [c4#x AS c3#x]
 :        +- Project [c4#x]
 :           +- SubqueryAlias w4
 :              +- CTERelationRef xxxx, true, [c4#x], false, false
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias w2
 :     +- Project [c3#x AS c2#x]
 :        +- Project [c3#x]
 :           +- SubqueryAlias w3
 :              +- CTERelationRef xxxx, true, [c3#x], false, false
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias w1
 :     +- Project [c2#x AS c1#x]
 :        +- Project [c2#x]
@@ -379,7 +379,7 @@ WITH same_name AS (SELECT 42)
 SELECT * FROM same_name, (SELECT 10) AS same_name
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias same_name
 :     +- Project [42 AS 42#x]
 :        +- OneRowRelation
@@ -419,7 +419,7 @@ WITH q AS (SELECT 'foo' AS x)
 SELECT x, typeof(x) FROM q
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias q
 :     +- Project [foo AS x#x]
 :        +- OneRowRelation
@@ -479,7 +479,7 @@ SELECT * FROM
 Project [y#x]
 +- SubqueryAlias __auto_generated_subquery_name
    +- WithCTE
-      :- CTERelationDef xxxx, false, false
+      :- CTERelationDef xxxx, false
       :  +- SubqueryAlias q
       :     +- Project [1 AS x#x]
       :        +- OneRowRelation
@@ -493,7 +493,7 @@ select (with q as (select 1 x) select * from q)
 -- !query analysis
 Project [scalar-subquery#x [] AS scalarsubquery()#x]
 :  +- WithCTE
-:     :- CTERelationDef xxxx, false, false
+:     :- CTERelationDef xxxx, false
 :     :  +- SubqueryAlias q
 :     :     +- Project [1 AS x#x]
 :     :        +- OneRowRelation
@@ -508,7 +508,7 @@ select 1 in (with q as (select 1) select * from q)
 -- !query analysis
 Project [1 IN (list#x []) AS (1 IN (listquery()))#x]
 :  +- WithCTE
-:     :- CTERelationDef xxxx, false, false
+:     :- CTERelationDef xxxx, false
 :     :  +- SubqueryAlias q
 :     :     +- Project [1 AS 1#x]
 :     :        +- OneRowRelation
@@ -549,11 +549,11 @@ from
   T1 z
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias T1
 :     +- Project [1 AS a#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias T1
 :     +- Project [2 AS b#x]
 :        +- OneRowRelation
@@ -580,15 +580,15 @@ from
   (WITH TtTt as (select 3 c) select * from ttTT, `tttT_2`)
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias TTtt
 :     +- Project [1 AS a#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias tTTt_2
 :     +- Project [2 AS a#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias TtTt
 :     +- Project [3 AS c#x]
 :        +- OneRowRelation
@@ -609,7 +609,7 @@ from (select 1 x, 2 y) T
 -- !query analysis
 Project [scalar-subquery#x [x#x] AS scalarsubquery(x)#x]
 :  +- WithCTE
-:     :- CTERelationDef xxxx, false, false
+:     :- CTERelationDef xxxx, false
 :     :  +- SubqueryAlias q
 :     :     +- Project [outer(x#x)]
 :     :        +- OneRowRelation
@@ -628,7 +628,7 @@ from (select 1 x, 2 y) T
 -- !query analysis
 Project [scalar-subquery#x [x#x && y#x] AS scalarsubquery(x, y)#x]
 :  +- WithCTE
-:     :- CTERelationDef xxxx, false, false
+:     :- CTERelationDef xxxx, false
 :     :  +- SubqueryAlias q
 :     :     +- Project [3 AS z#x]
 :     :        +- OneRowRelation
@@ -646,11 +646,11 @@ select * from
   (with q2 as (select * from q1) select * from q2)
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias q1
 :     +- Project [1 AS x#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias q2
 :     +- Project [x#x]
 :        +- SubqueryAlias q1
@@ -668,11 +668,11 @@ select * from
   (with q1 as (select x+1 from q1) select * from q1)
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias q1
 :     +- Project [1 AS x#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias q1
 :     +- Project [(x#x + 1) AS (x + 1)#x]
 :        +- SubqueryAlias q1
@@ -709,7 +709,7 @@ with cte1 as (Select id as j from t)
 select * from cte1 where j = (select max(j) from cte1 as cte2)
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte1
 :     +- Project [id#x AS j#x]
 :        +- SubqueryAlias t
diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/double-quoted-identifiers-enabled.sql.out
 
b/sql/core/src/test/resources/sql-tests/analyzer-results/double-quoted-identifiers-enabled.sql.out
index 35713167bc38..f2b1d91d7e44 100644
--- 
a/sql/core/src/test/resources/sql-tests/analyzer-results/double-quoted-identifiers-enabled.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/analyzer-results/double-quoted-identifiers-enabled.sql.out
@@ -411,7 +411,7 @@ CREATE TEMPORARY VIEW "myview"("c1") AS
 -- !query analysis
 CreateViewCommand `myview`, [(c1,None)], WITH "v"("a") AS (SELECT 1) SELECT 
"a" FROM "v", false, false, LocalTempView, UNSUPPORTED, true
    +- WithCTE
-      :- CTERelationDef xxxx, false, false
+      :- CTERelationDef xxxx, false
       :  +- SubqueryAlias v
       :     +- Project [1#x AS a#x]
       :        +- Project [1 AS 1#x]
@@ -431,7 +431,7 @@ Project [a1#x AS a2#x]
          +- View (`myview`, [c1#x])
             +- Project [cast(a#x as int) AS c1#x]
                +- WithCTE
-                  :- CTERelationDef xxxx, false, false
+                  :- CTERelationDef xxxx, false
                   :  +- SubqueryAlias v
                   :     +- Project [1#x AS a#x]
                   :        +- Project [1 AS 1#x]
diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/identifier-clause.sql.out
 
b/sql/core/src/test/resources/sql-tests/analyzer-results/identifier-clause.sql.out
index 9384f17fa74c..87d537f94981 100644
--- 
a/sql/core/src/test/resources/sql-tests/analyzer-results/identifier-clause.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/analyzer-results/identifier-clause.sql.out
@@ -1012,11 +1012,11 @@ WITH S(c1, c2) AS (VALUES(1, 2), (2, 3)),
 SELECT IDENTIFIER(agg)(IDENTIFIER(col)) FROM IDENTIFIER(tab)
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias S
 :     +- Project [col1#x AS c1#x, col2#x AS c2#x]
 :        +- LocalRelation [col1#x, col2#x]
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias T
 :     +- Project [col1#x AS c1#x, col2#x AS c2#x]
 :        +- LocalRelation [col1#x, col2#x]
@@ -1031,11 +1031,11 @@ WITH S(c1, c2) AS (VALUES(1, 2), (2, 3)),
 SELECT IDENTIFIER('max')(IDENTIFIER('c1')) FROM IDENTIFIER('T')
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias S
 :     +- Project [col1#x AS c1#x, col2#x AS c2#x]
 :        +- LocalRelation [col1#x, col2#x]
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias T
 :     +- Project [col1#x AS c1#x, col2#x AS c2#x]
 :        +- LocalRelation [col1#x, col2#x]
@@ -1049,7 +1049,7 @@ WITH ABC(c1, c2) AS (VALUES(1, 2), (2, 3))
 SELECT IDENTIFIER('max')(IDENTIFIER('c1')) FROM IDENTIFIER('A' || 'BC')
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias ABC
 :     +- Project [col1#x AS c1#x, col2#x AS c2#x]
 :        +- LocalRelation [col1#x, col2#x]
diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/join-lateral.sql.out 
b/sql/core/src/test/resources/sql-tests/analyzer-results/join-lateral.sql.out
index c93109e42836..390fcf5e3015 100644
--- 
a/sql/core/src/test/resources/sql-tests/analyzer-results/join-lateral.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/analyzer-results/join-lateral.sql.out
@@ -1358,14 +1358,14 @@ WITH cte1 AS (
 SELECT * FROM cte2
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte1
 :     +- Project [c1#x]
 :        +- SubqueryAlias spark_catalog.default.t1
 :           +- View (`spark_catalog`.`default`.`t1`, [c1#x, c2#x])
 :              +- Project [cast(col1#x as int) AS c1#x, cast(col2#x as int) AS 
c2#x]
 :                 +- LocalRelation [col1#x, col2#x]
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte2
 :     +- Project [c1#x, c2#x]
 :        +- LateralJoin lateral-subquery#x [c1#x], Inner
diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/non-excludable-rule.sql.out
 
b/sql/core/src/test/resources/sql-tests/analyzer-results/non-excludable-rule.sql.out
index 7f1ca3dda902..4a717488e017 100644
--- 
a/sql/core/src/test/resources/sql-tests/analyzer-results/non-excludable-rule.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/analyzer-results/non-excludable-rule.sql.out
@@ -36,7 +36,7 @@ WITH tmp AS (
 SELECT id FROM range(3) WHERE id > (SELECT max(id) FROM tmp)
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias tmp
 :     +- Intersect false
 :        :- Project [id#xL]
diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/postgreSQL/window_part3.sql.out
 
b/sql/core/src/test/resources/sql-tests/analyzer-results/postgreSQL/window_part3.sql.out
index 441b3627bc92..2b2d69db348d 100644
--- 
a/sql/core/src/test/resources/sql-tests/analyzer-results/postgreSQL/window_part3.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/analyzer-results/postgreSQL/window_part3.sql.out
@@ -89,7 +89,7 @@ FROM cte
 WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following)
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte
 :     +- Project [id#xL AS x#xL]
 :        +- Project [id#xL]
@@ -111,7 +111,7 @@ FROM cte
 WINDOW w AS (ORDER BY x range between 1 preceding and 1 following)
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte
 :     +- Project [id#xL AS x#xL]
 :        +- Project [id#xL]
@@ -134,7 +134,7 @@ FROM cte
 WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following)
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte
 :     +- Project [1#xL AS x#xL]
 :        +- Union false, false
@@ -167,7 +167,7 @@ FROM cte
 WINDOW w AS (ORDER BY x range between 1 preceding and 1 following)
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte
 :     +- Project [1#xL AS x#xL]
 :        +- Union false, false
diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/postgreSQL/with.sql.out
 
b/sql/core/src/test/resources/sql-tests/analyzer-results/postgreSQL/with.sql.out
index b92e70e91a4b..1219562068dd 100644
--- 
a/sql/core/src/test/resources/sql-tests/analyzer-results/postgreSQL/with.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/analyzer-results/postgreSQL/with.sql.out
@@ -4,7 +4,7 @@ WITH q1(x,y) AS (SELECT 1,2)
 SELECT * FROM q1, q1 AS q2
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias q1
 :     +- Project [1#x AS x#x, 2#x AS y#x]
 :        +- Project [1 AS 1#x, 2 AS 2#x]
@@ -185,7 +185,7 @@ InsertIntoHadoopFsRelationCommand file:[not included in 
comparison]/{warehouse_d
 with cte(foo) as ( select 42 ) select * from ((select foo from cte)) q
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte
 :     +- Project [42#x AS foo#x]
 :        +- Project [42 AS 42#x]
@@ -207,11 +207,11 @@ WITH outermost(x) AS (
 SELECT * FROM outermost ORDER BY 1
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias innermost
 :     +- Project [2 AS 2#x]
 :        +- OneRowRelation
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias outermost
 :     +- Project [1#x AS x#x]
 :        +- Distinct
@@ -412,7 +412,7 @@ org.apache.spark.sql.catalyst.parser.ParseException
 with ordinality as (select 1 as x) select * from ordinality
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias ordinality
 :     +- Project [1 AS x#x]
 :        +- OneRowRelation
@@ -453,7 +453,7 @@ with test as (select 42) insert into test select * from test
 InsertIntoHadoopFsRelationCommand file:[not included in 
comparison]/{warehouse_dir}/test, false, Parquet, [path=file:[not included in 
comparison]/{warehouse_dir}/test], Append, `spark_catalog`.`default`.`test`, 
org.apache.spark.sql.execution.datasources.InMemoryFileIndex(file:[not included 
in comparison]/{warehouse_dir}/test), [i]
 +- Project [cast(42#x as int) AS i#x]
    +- WithCTE
-      :- CTERelationDef xxxx, false, false
+      :- CTERelationDef xxxx, false
       :  +- SubqueryAlias test
       :     +- Project [42 AS 42#x]
       :        +- OneRowRelation
diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/sql-session-variables.sql.out
 
b/sql/core/src/test/resources/sql-tests/analyzer-results/sql-session-variables.sql.out
index da4542fe9bb1..77e7174167ec 100644
--- 
a/sql/core/src/test/resources/sql-tests/analyzer-results/sql-session-variables.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/analyzer-results/sql-session-variables.sql.out
@@ -2044,7 +2044,7 @@ Project [1 AS 1#x]
 WITH v1 AS (SELECT var1 AS c1) SELECT c1 AS `1` FROM v1
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias v1
 :     +- Project [variablereference(system.session.var1=1) AS c1#x]
 :        +- OneRowRelation
diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/subquery/exists-subquery/exists-cte.sql.out
 
b/sql/core/src/test/resources/sql-tests/analyzer-results/subquery/exists-subquery/exists-cte.sql.out
index f210bc49030f..abaf6a243225 100644
--- 
a/sql/core/src/test/resources/sql-tests/analyzer-results/subquery/exists-subquery/exists-cte.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/analyzer-results/subquery/exists-subquery/exists-cte.sql.out
@@ -101,7 +101,7 @@ WHERE  a.bonus_amt > 30
                    WHERE  a.emp_name = b.emp_name)
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias bonus_cte
 :     +- Project [emp_name#x, bonus_amt#x]
 :        +- Filter exists#x [emp_name#x]
@@ -162,7 +162,7 @@ WHERE  EXISTS (SELECT *
                WHERE  bonus.emp_name = a.emp_name)
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias emp_cte
 :     +- Project [id#x, emp_name#x, hiredate#x, salary#x, dept_id#x]
 :        +- Filter ((id#x >= 100) AND (id#x <= 300))
@@ -172,7 +172,7 @@ WithCTE
 :                    +- Project [id#x, emp_name#x, hiredate#x, salary#x, 
dept_id#x]
 :                       +- SubqueryAlias EMP
 :                          +- LocalRelation [id#x, emp_name#x, hiredate#x, 
salary#x, dept_id#x]
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias dept_cte
 :     +- Project [dept_id#x, dept_name#x, state#x]
 :        +- Filter (dept_id#x = 10)
@@ -225,7 +225,7 @@ WHERE  e.dept_id = d.dept_id
                    WHERE  e.emp_name = a.emp_name)
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias emp_cte
 :     +- Project [id#x, emp_name#x, hiredate#x, salary#x, dept_id#x]
 :        +- Filter ((id#x >= 100) AND (id#x <= 300))
@@ -235,7 +235,7 @@ WithCTE
 :                    +- Project [id#x, emp_name#x, hiredate#x, salary#x, 
dept_id#x]
 :                       +- SubqueryAlias EMP
 :                          +- LocalRelation [id#x, emp_name#x, hiredate#x, 
salary#x, dept_id#x]
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias dept_cte
 :     +- Project [dept_id#x, dept_name#x, state#x]
 :        +- Filter (dept_id#x = 10)
@@ -299,7 +299,7 @@ WHERE  EXISTS (SELECT dept_id,
 GROUP  BY emp_name
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias empdept
 :     +- Project [id#x, salary#x, emp_name#x, dept_id#x]
 :        +- Filter id#x IN (100,200)
@@ -352,7 +352,7 @@ WHERE  NOT EXISTS (SELECT dept_id,
 GROUP  BY emp_name
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias empdept
 :     +- Project [id#x, salary#x, emp_name#x, dept_id#x]
 :        +- Filter id#x IN (100,200)
diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/subquery/in-subquery/in-multiple-columns.sql.out
 
b/sql/core/src/test/resources/sql-tests/analyzer-results/subquery/in-subquery/in-multiple-columns.sql.out
index 85e28de736a0..230ffc005e90 100644
--- 
a/sql/core/src/test/resources/sql-tests/analyzer-results/subquery/in-subquery/in-multiple-columns.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/analyzer-results/subquery/in-subquery/in-multiple-columns.sql.out
@@ -307,7 +307,7 @@ FROM            (
                            on         cte1.t1b = cte2.t1b) s
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte1
 :     +- Project [t1a#x, t1b#x]
 :        +- Filter named_struct(t1b, t1b#x, t1d, t1d#xL) IN (list#x [t1c#x])
diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/subquery/in-subquery/in-with-cte.sql.out
 
b/sql/core/src/test/resources/sql-tests/analyzer-results/subquery/in-subquery/in-with-cte.sql.out
index 03a4c3ffd4fc..199b876fb9a8 100644
--- 
a/sql/core/src/test/resources/sql-tests/analyzer-results/subquery/in-subquery/in-with-cte.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/analyzer-results/subquery/in-subquery/in-with-cte.sql.out
@@ -123,7 +123,7 @@ WHERE  t1b IN (SELECT cte1.t1b
                WHERE  cte1.t1b > 0)
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte1
 :     +- Project [t1a#x, t1b#x]
 :        +- Filter (t1a#x = val1a)
@@ -177,7 +177,7 @@ GROUP BY t1a, t1b, t1c
 HAVING t1c IS NOT NULL
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte1
 :     +- Project [t1a#x, t1b#x]
 :        +- SubqueryAlias t1
@@ -250,7 +250,7 @@ WHERE  t1c IN
               ON              cte1.t1d > cte6.t1d)
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte1
 :     +- Project [t1a#x, t1b#x, t1c#x, t1d#xL, t1e#x]
 :        +- SubqueryAlias t1
@@ -316,7 +316,7 @@ FROM   (SELECT *
                        ON cte1.t1b = cte4.t1b) s
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte1
 :     +- Project [t1a#x, t1b#x]
 :        +- Filter (t1b#x IN (list#x []) AND (t1a#x = val1b))
@@ -393,7 +393,7 @@ WHERE    t1b IN
 GROUP BY t1b
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte1
 :     +- Project [t1a#x, t1b#x, t1h#x]
 :        +- Filter t1a#x IN (list#x [t1b#x])
@@ -453,7 +453,7 @@ FROM            (
                        ) s
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte1
 :     +- Project [t1a#x, t1b#x, t1c#x]
 :        +- Filter (t1b#x IN (list#x [t1c#x]) AND (t1a#x = val1b))
@@ -515,7 +515,7 @@ FROM   (SELECT cte1.t1a,
 GROUP  BY s.t1b
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte1
 :     +- Project [t1a#x, t1b#x]
 :        +- Filter t1b#x IN (list#x [t1c#x])
@@ -569,7 +569,7 @@ WHERE           s.t1b IN
                        ON     t1.t1a = cte1.t1a)
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte1
 :     +- Project [t1a#x, t1b#x]
 :        +- Filter t1b#x IN (list#x [t1c#x])
@@ -627,7 +627,7 @@ WHERE  t1b NOT IN (SELECT cte1.t1b
        t1c > 10
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte1
 :     +- Project [t1a#x, t1b#x]
 :        +- Filter (t1a#x = val1d)
@@ -683,7 +683,7 @@ WHERE    t1b NOT IN
 ORDER BY t1c DESC
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias cte1
 :     +- Project [t1a#x, t1b#x, t1c#x, t1d#xL, t1h#x]
 :        +- Filter NOT t1d#xL IN (list#x [])
diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/subquery/scalar-subquery/scalar-subquery-select.sql.out
 
b/sql/core/src/test/resources/sql-tests/analyzer-results/subquery/scalar-subquery/scalar-subquery-select.sql.out
index 3b1ffa94c17f..2a3a87e5cab8 100644
--- 
a/sql/core/src/test/resources/sql-tests/analyzer-results/subquery/scalar-subquery/scalar-subquery-select.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/analyzer-results/subquery/scalar-subquery/scalar-subquery-select.sql.out
@@ -617,7 +617,7 @@ SELECT c1, (WITH t AS (SELECT 1 AS a) SELECT a + c1 FROM t) 
FROM t1
 -- !query analysis
 Project [c1#x, scalar-subquery#x [c1#x] AS scalarsubquery(c1)#x]
 :  +- WithCTE
-:     :- CTERelationDef xxxx, false, false
+:     :- CTERelationDef xxxx, false
 :     :  +- SubqueryAlias t
 :     :     +- Project [1 AS a#x]
 :     :        +- OneRowRelation
@@ -636,7 +636,7 @@ SELECT c1, (WITH t AS (SELECT * FROM t2 WHERE c1 = t1.c1) 
SELECT SUM(c2) FROM t)
 -- !query analysis
 Project [c1#x, scalar-subquery#x [c1#x] AS scalarsubquery(c1)#xL]
 :  +- WithCTE
-:     :- CTERelationDef xxxx, false, false
+:     :- CTERelationDef xxxx, false
 :     :  +- SubqueryAlias t
 :     :     +- Project [c1#x, c2#x]
 :     :        +- Filter (c1#x = outer(c1#x))
@@ -664,7 +664,7 @@ SELECT c1, (
 -- !query analysis
 Project [c1#x, scalar-subquery#x [c1#x] AS scalarsubquery(c1)#xL]
 :  +- WithCTE
-:     :- CTERelationDef xxxx, false, false
+:     :- CTERelationDef xxxx, false
 :     :  +- SubqueryAlias t3
 :     :     +- Project [(c1#x + 1) AS c1#x, (c2#x + 1) AS c2#x]
 :     :        +- SubqueryAlias t2
@@ -672,7 +672,7 @@ Project [c1#x, scalar-subquery#x [c1#x] AS 
scalarsubquery(c1)#xL]
 :     :              +- Project [cast(c1#x as int) AS c1#x, cast(c2#x as int) 
AS c2#x]
 :     :                 +- SubqueryAlias t2
 :     :                    +- LocalRelation [c1#x, c2#x]
-:     :- CTERelationDef xxxx, false, false
+:     :- CTERelationDef xxxx, false
 :     :  +- SubqueryAlias t4
 :     :     +- Project [c1#x, c2#x]
 :     :        +- Filter (outer(c1#x) = c1#x)
@@ -697,7 +697,7 @@ SELECT c1, (
 -- !query analysis
 Project [c1#x, scalar-subquery#x [c1#x] AS scalarsubquery(c1)#xL]
 :  +- WithCTE
-:     :- CTERelationDef xxxx, false, false
+:     :- CTERelationDef xxxx, false
 :     :  +- SubqueryAlias t
 :     :     +- Project [c1#x, c2#x]
 :     :        +- SubqueryAlias t2
@@ -732,7 +732,7 @@ SELECT * FROM t1 WHERE c1 > (
 )
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias v
 :     +- Project [c1#x, c2#x]
 :        +- SubqueryAlias t2
@@ -743,7 +743,7 @@ WithCTE
 +- Project [c1#x, c2#x]
    +- Filter (cast(c1#x as bigint) > scalar-subquery#x [c1#x])
       :  +- WithCTE
-      :     :- CTERelationDef xxxx, false, false
+      :     :- CTERelationDef xxxx, false
       :     :  +- SubqueryAlias t
       :     :     +- Project [c1#x, c2#x]
       :     :        +- SubqueryAlias t2
@@ -771,7 +771,7 @@ WITH t AS (SELECT 1 AS a)
 SELECT c1, (SELECT a FROM t WHERE a = c1) FROM t1
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t
 :     +- Project [1 AS a#x]
 :        +- OneRowRelation
@@ -1019,7 +1019,7 @@ SELECT (SELECT sum(1) FROM T WHERE a = col OR upper(col)= 
'Y')
 FROM (SELECT null as col) as foo
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias T
 :     +- Project [1 AS a#x]
 :        +- OneRowRelation
diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/transform.sql.out 
b/sql/core/src/test/resources/sql-tests/analyzer-results/transform.sql.out
index 04e019fdbaa4..d5376913f9ae 100644
--- a/sql/core/src/test/resources/sql-tests/analyzer-results/transform.sql.out
+++ b/sql/core/src/test/resources/sql-tests/analyzer-results/transform.sql.out
@@ -874,7 +874,7 @@ WITH temp AS (
 SELECT t1.b FROM temp t1 JOIN temp t2 ON t1.b = t2.b
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias temp
 :     +- ScriptTransformation cat, [b#x], 
ScriptInputOutputSchema(List(),List(),None,None,List(),List(),None,None,false)
 :        +- Project [a#x]
diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/using-join.sql.out 
b/sql/core/src/test/resources/sql-tests/analyzer-results/using-join.sql.out
index 89f988fe2b61..d26c5ba4430d 100644
--- a/sql/core/src/test/resources/sql-tests/analyzer-results/using-join.sql.out
+++ b/sql/core/src/test/resources/sql-tests/analyzer-results/using-join.sql.out
@@ -817,12 +817,12 @@ FROM t1 FULL OUTER JOIN t2 USING (key)
 WHERE t1.key NOT LIKE 'bb.%'
 -- !query analysis
 WithCTE
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t1
 :     +- Project [key#x]
 :        +- SubqueryAlias t
 :           +- LocalRelation [key#x]
-:- CTERelationDef xxxx, false, false
+:- CTERelationDef xxxx, false
 :  +- SubqueryAlias t2
 :     +- Project [key#x]
 :        +- SubqueryAlias t
diff --git 
a/sql/core/src/test/resources/sql-tests/results/keywords-enforced.sql.out 
b/sql/core/src/test/resources/sql-tests/results/keywords-enforced.sql.out
index 7d96a3e98c83..f9c9df3f9bf5 100644
--- a/sql/core/src/test/resources/sql-tests/results/keywords-enforced.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/keywords-enforced.sql.out
@@ -252,6 +252,7 @@ REAL        false
 RECORDREADER   false
 RECORDWRITER   false
 RECOVER        false
+RECURSIVE      true
 REDUCE false
 REFERENCES     true
 REFRESH        false
@@ -432,6 +433,7 @@ ORDER
 OUTER
 OVERLAPS
 PRIMARY
+RECURSIVE
 REFERENCES
 RIGHT
 SELECT
diff --git a/sql/core/src/test/resources/sql-tests/results/keywords.sql.out 
b/sql/core/src/test/resources/sql-tests/results/keywords.sql.out
index 6cbfe519a76f..67e5e4170d78 100644
--- a/sql/core/src/test/resources/sql-tests/results/keywords.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/keywords.sql.out
@@ -252,6 +252,7 @@ REAL        false
 RECORDREADER   false
 RECORDWRITER   false
 RECOVER        false
+RECURSIVE      false
 REDUCE false
 REFERENCES     false
 REFRESH        false
diff --git 
a/sql/core/src/test/resources/sql-tests/results/nonansi/keywords.sql.out 
b/sql/core/src/test/resources/sql-tests/results/nonansi/keywords.sql.out
index 6cbfe519a76f..67e5e4170d78 100644
--- a/sql/core/src/test/resources/sql-tests/results/nonansi/keywords.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/nonansi/keywords.sql.out
@@ -252,6 +252,7 @@ REAL        false
 RECORDREADER   false
 RECORDWRITER   false
 RECOVER        false
+RECURSIVE      false
 REDUCE false
 REFERENCES     false
 REFRESH        false
diff --git 
a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/ThriftServerWithSparkContextSuite.scala
 
b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/ThriftServerWithSparkContextSuite.scala
index 2acf25640ef7..da0ddd3a156f 100644
--- 
a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/ThriftServerWithSparkContextSuite.scala
+++ 
b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/ThriftServerWithSparkContextSuite.scala
@@ -214,7 +214,7 @@ trait ThriftServerWithSparkContextSuite extends 
SharedThriftServer {
       val sessionHandle = client.openSession(user, "")
       val infoValue = client.getInfo(sessionHandle, 
GetInfoType.CLI_ODBC_KEYWORDS)
       // scalastyle:off line.size.limit
-      assert(infoValue.getStringValue == 
"ADD,AFTER,AGGREGATE,ALL,ALTER,ALWAYS,ANALYZE,AND,ANTI,ANY,ANY_VALUE,ARCHIVE,ARRAY,AS,ASC,AT,AUTHORIZATION,BEGIN,BETWEEN,BIGINT,BINARY,BINDING,BOOLEAN,BOTH,BUCKET,BUCKETS,BY,BYTE,CACHE,CALL,CALLED,CASCADE,CASE,CAST,CATALOG,CATALOGS,CHANGE,CHAR,CHARACTER,CHECK,CLEAR,CLUSTER,CLUSTERED,CODEGEN,COLLATE,COLLATION,COLLECTION,COLUMN,COLUMNS,COMMENT,COMMIT,COMPACT,COMPACTIONS,COMPENSATION,COMPUTE,CONCATENATE,CONSTRAINT,CONTAINS,COST,CREATE,CROSS,CUBE,CURR
 [...]
+      assert(infoValue.getStringValue == 
"ADD,AFTER,AGGREGATE,ALL,ALTER,ALWAYS,ANALYZE,AND,ANTI,ANY,ANY_VALUE,ARCHIVE,ARRAY,AS,ASC,AT,AUTHORIZATION,BEGIN,BETWEEN,BIGINT,BINARY,BINDING,BOOLEAN,BOTH,BUCKET,BUCKETS,BY,BYTE,CACHE,CALL,CALLED,CASCADE,CASE,CAST,CATALOG,CATALOGS,CHANGE,CHAR,CHARACTER,CHECK,CLEAR,CLUSTER,CLUSTERED,CODEGEN,COLLATE,COLLATION,COLLECTION,COLUMN,COLUMNS,COMMENT,COMMIT,COMPACT,COMPACTIONS,COMPENSATION,COMPUTE,CONCATENATE,CONSTRAINT,CONTAINS,COST,CREATE,CROSS,CUBE,CURR
 [...]
       // scalastyle:on line.size.limit
     }
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to