From 738daed374bd22bb1875e96ab1a3a7f67d6e72fd Mon Sep 17 00:00:00 2001 From: "sundar.shankar" Date: Mon, 14 Oct 2024 17:34:47 +0530 Subject: [PATCH 01/12] Init Commit for With Recursive --- .../labs/remorph/parsers/snowflake/SnowflakeParser.g4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 b/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 index 307add05c..ce17eebdf 100644 --- a/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 +++ b/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 @@ -3329,7 +3329,7 @@ switchSection: WHEN expr THEN expr queryStatement: withExpression? selectStatement setOperators* ; -withExpression: WITH commonTableExpression (COMMA commonTableExpression)* +withExpression: WITH RECURSIVE? commonTableExpression (COMMA commonTableExpression)* ; commonTableExpression From bc0b694066d5c11cea8c87131e234dfd05248af9 Mon Sep 17 00:00:00 2001 From: "sundar.shankar" Date: Fri, 18 Oct 2024 11:59:32 +0530 Subject: [PATCH 02/12] Grammar Changes --- .../labs/remorph/parsers/snowflake/SnowflakeParser.g4 | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 b/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 index ce17eebdf..36c3a857c 100644 --- a/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 +++ b/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 @@ -3332,11 +3332,9 @@ queryStatement: withExpression? selectStatement setOperators* withExpression: WITH RECURSIVE? commonTableExpression (COMMA commonTableExpression)* ; -commonTableExpression - : tableName = id (L_PAREN columns += id (COMMA columns += id)* R_PAREN)? AS L_PAREN ( - (selectStatement setOperators*) - | expr - ) R_PAREN +commonTableExpression: id (L_PAREN columnList R_PAREN)? AS L_PAREN ( +(selectStatement setOperators*) +| expr) R_PAREN ; selectStatement From 0f77b0bb8ba7027ce5116a60389a4319a15a1838 Mon Sep 17 00:00:00 2001 From: "sundar.shankar" Date: Fri, 18 Oct 2024 12:36:03 +0530 Subject: [PATCH 03/12] Grammar Changes --- .../labs/remorph/parsers/snowflake/SnowflakeParser.g4 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 b/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 index 36c3a857c..90f73aea3 100644 --- a/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 +++ b/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 @@ -3332,9 +3332,8 @@ queryStatement: withExpression? selectStatement setOperators* withExpression: WITH RECURSIVE? commonTableExpression (COMMA commonTableExpression)* ; -commonTableExpression: id (L_PAREN columnList R_PAREN)? AS L_PAREN ( -(selectStatement setOperators*) -| expr) R_PAREN +commonTableExpression +: id (L_PAREN columnList R_PAREN)? AS L_PAREN ((selectStatement setOperators*)| expr) R_PAREN ; selectStatement From 1d00a10227e29b4e29a260bfb5568ae55058e75b Mon Sep 17 00:00:00 2001 From: "sundar.shankar" Date: Fri, 18 Oct 2024 14:51:29 +0530 Subject: [PATCH 04/12] visitor changes --- .../labs/remorph/parsers/snowflake/SnowflakeParser.g4 | 2 +- .../parsers/snowflake/SnowflakeRelationBuilder.scala | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 b/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 index 90f73aea3..8b721c25c 100644 --- a/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 +++ b/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 @@ -3333,7 +3333,7 @@ withExpression: WITH RECURSIVE? commonTableExpression (COMMA commonTableExpressi ; commonTableExpression -: id (L_PAREN columnList R_PAREN)? AS L_PAREN ((selectStatement setOperators*)| expr) R_PAREN + : id (L_PAREN columnList R_PAREN)? AS L_PAREN ((selectStatement setOperators*) | expr) R_PAREN ; selectStatement diff --git a/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeRelationBuilder.scala b/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeRelationBuilder.scala index 27449eace..e649777de 100644 --- a/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeRelationBuilder.scala +++ b/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeRelationBuilder.scala @@ -292,8 +292,12 @@ class SnowflakeRelationBuilder(override val vc: SnowflakeVisitorCoordinator) } override def visitCommonTableExpression(ctx: CommonTableExpressionContext): ir.LogicalPlan = { - val tableName = vc.expressionBuilder.visitId(ctx.tableName) - val columns = ctx.columns.asScala.map(vc.expressionBuilder.visitId) + val tableName = vc.expressionBuilder.visitId(ctx.id) + val columns = ctx + .columnList() + .columnName() + .asScala.flatMap(_.id.asScala.map(vc.expressionBuilder.visitId)) + val query = ctx.selectStatement().accept(this) ir.SubqueryAlias(query, tableName, columns) } From 1663e4533316a4e2d660e729f0d00ab8c69a95db Mon Sep 17 00:00:00 2001 From: "sundar.shankar" Date: Fri, 18 Oct 2024 15:41:41 +0530 Subject: [PATCH 05/12] Fixed Test cases --- .../parsers/snowflake/SnowflakeRelationBuilder.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeRelationBuilder.scala b/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeRelationBuilder.scala index e649777de..c92ce0a5f 100644 --- a/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeRelationBuilder.scala +++ b/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeRelationBuilder.scala @@ -293,10 +293,10 @@ class SnowflakeRelationBuilder(override val vc: SnowflakeVisitorCoordinator) override def visitCommonTableExpression(ctx: CommonTableExpressionContext): ir.LogicalPlan = { val tableName = vc.expressionBuilder.visitId(ctx.id) - val columns = ctx - .columnList() - .columnName() - .asScala.flatMap(_.id.asScala.map(vc.expressionBuilder.visitId)) + val columns = ctx.columnList() match { + case null => Seq.empty[ir.Id] + case c => c.columnName().asScala.flatMap(_.id.asScala.map(vc.expressionBuilder.visitId)) + } val query = ctx.selectStatement().accept(this) ir.SubqueryAlias(query, tableName, columns) From 6c19775bba13f4bd8e4275172e22a6e1937e8f14 Mon Sep 17 00:00:00 2001 From: "sundar.shankar" Date: Fri, 25 Oct 2024 12:32:20 +0530 Subject: [PATCH 06/12] merged main branch --- .../labs/remorph/parsers/snowflake/SnowflakeParser.g4 | 2 +- .../remorph/parsers/snowflake/SnowflakeRelationBuilder.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 b/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 index 8b721c25c..625f30443 100644 --- a/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 +++ b/core/src/main/antlr4/com/databricks/labs/remorph/parsers/snowflake/SnowflakeParser.g4 @@ -3333,7 +3333,7 @@ withExpression: WITH RECURSIVE? commonTableExpression (COMMA commonTableExpressi ; commonTableExpression - : id (L_PAREN columnList R_PAREN)? AS L_PAREN ((selectStatement setOperators*) | expr) R_PAREN + : tableName = id (L_PAREN columnList R_PAREN)? AS L_PAREN ((selectStatement setOperators*) | expr) R_PAREN ; selectStatement diff --git a/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeRelationBuilder.scala b/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeRelationBuilder.scala index 5b7f187ad..b384689c2 100644 --- a/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeRelationBuilder.scala +++ b/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeRelationBuilder.scala @@ -329,7 +329,7 @@ class SnowflakeRelationBuilder(override val vc: SnowflakeVisitorCoordinator) case Some(errorResult) => errorResult case None => val tableName = vc.expressionBuilder.buildId(ctx.tableName) - val columns = ctx.columnList() match { + val columns = ctx.columnList() match { case null => Seq.empty[ir.Id] case c => c.columnName().asScala.flatMap(_.id.asScala.map(vc.expressionBuilder.buildId)) } From ab8d161992024830d0a2db286cb736c2e94fcaae Mon Sep 17 00:00:00 2001 From: "sundar.shankar" Date: Fri, 25 Oct 2024 13:49:34 +0530 Subject: [PATCH 07/12] merged main branch --- .../parsers/snowflake/SnowflakeRelationBuilder.scala | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeRelationBuilder.scala b/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeRelationBuilder.scala index b384689c2..973146816 100644 --- a/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeRelationBuilder.scala +++ b/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeRelationBuilder.scala @@ -324,15 +324,14 @@ class SnowflakeRelationBuilder(override val vc: SnowflakeVisitorCoordinator) .getOrElse(ir.UnspecifiedJoin) } - override def visitCommonTableExpression(ctx: CommonTableExpressionContext): ir.LogicalPlan = errorCheck(ctx) match { case Some(errorResult) => errorResult case None => val tableName = vc.expressionBuilder.buildId(ctx.tableName) val columns = ctx.columnList() match { - case null => Seq.empty[ir.Id] - case c => c.columnName().asScala.flatMap(_.id.asScala.map(vc.expressionBuilder.buildId)) - } + case null => Seq.empty[ir.Id] + case c => c.columnName().asScala.flatMap(_.id.asScala.map(vc.expressionBuilder.buildId)) + } val query = ctx.selectStatement().accept(this) ir.SubqueryAlias(query, tableName, columns) From 1644849ea3656972a6985f4d7a568738f9427bae Mon Sep 17 00:00:00 2001 From: "sundar.shankar" Date: Fri, 25 Oct 2024 15:52:08 +0530 Subject: [PATCH 08/12] intermediate commit --- .../core_engine/test_cte/recursive_cte.sql | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/resources/functional/snowflake/core_engine/test_cte/recursive_cte.sql diff --git a/tests/resources/functional/snowflake/core_engine/test_cte/recursive_cte.sql b/tests/resources/functional/snowflake/core_engine/test_cte/recursive_cte.sql new file mode 100644 index 000000000..3b8cc37c0 --- /dev/null +++ b/tests/resources/functional/snowflake/core_engine/test_cte/recursive_cte.sql @@ -0,0 +1,27 @@ +-- snowflake sql: +WITH RECURSIVE employee_hierarchy AS ( + SELECT + employee_id, + manager_id, + employee_name, + 1 AS level + FROM + employees + WHERE + manager_id IS NULL + UNION ALL + SELECT + e.employee_id, + e.manager_id, + e.employee_name, + eh.level + 1 AS level + FROM + employees e + INNER JOIN + employee_hierarchy eh ON e.manager_id = eh.employee_id +) +SELECT * +FROM employee_hierarchy +ORDER BY level, employee_id; + +-- databricks sql: \ No newline at end of file From 670ae1126a5620c17ccd3284790139bf7e4c7787 Mon Sep 17 00:00:00 2001 From: "sundar.shankar" Date: Mon, 28 Oct 2024 11:01:09 +0530 Subject: [PATCH 09/12] Added Test Case --- .../snowflake/SnowflakeAstBuilder.scala | 14 ++++++++-- .../core_engine/test_cte/cte_simple.sql | 16 +++++++++++ .../core_engine/test_cte/recursive_cte.sql | 27 ++++++++++++++++++- 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 tests/resources/functional/snowflake/core_engine/test_cte/cte_simple.sql diff --git a/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeAstBuilder.scala b/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeAstBuilder.scala index 2b36d4991..1e2aa2430 100644 --- a/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeAstBuilder.scala +++ b/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeAstBuilder.scala @@ -82,9 +82,19 @@ class SnowflakeAstBuilder(override val vc: SnowflakeVisitorCoordinator) errorCheck(ctx) match { case Some(errorResult) => errorResult case None => - val ctes = vc.relationBuilder.visitMany(ctx.commonTableExpression()) - ir.WithCTE(ctes, relation) + if (ctx.RECURSIVE() == null) { + val ctes = vc.relationBuilder.visitMany(ctx.commonTableExpression()) + ir.WithCTE(ctes, relation) + } else { + ir.UnresolvedCommand( + ruleText = contextText(ctx), + message = "*** WITH RECURSIVE IS NOT SUPPORTED ***", + ruleName = vc.ruleName(ctx), + tokenName = Some(tokenName(ctx.getStart))) + } + } + } private def buildSetOperator(left: ir.LogicalPlan, ctx: SetOperatorsContext): ir.LogicalPlan = { diff --git a/tests/resources/functional/snowflake/core_engine/test_cte/cte_simple.sql b/tests/resources/functional/snowflake/core_engine/test_cte/cte_simple.sql new file mode 100644 index 000000000..25e60ae3f --- /dev/null +++ b/tests/resources/functional/snowflake/core_engine/test_cte/cte_simple.sql @@ -0,0 +1,16 @@ +-- snowflake sql: +WITH employee_hierarchy AS ( + SELECT + employee_id, + manager_id, + employee_name + FROM + employees + WHERE + manager_id IS NULL +) +SELECT * +FROM employee_hierarchy; + +-- databricks sql: +WITH employee_hierarchy AS (SELECT employee_id, manager_id, employee_name FROM employees WHERE manager_id IS NULL) SELECT * FROM employee_hierarchy; \ No newline at end of file diff --git a/tests/resources/functional/snowflake/core_engine/test_cte/recursive_cte.sql b/tests/resources/functional/snowflake/core_engine/test_cte/recursive_cte.sql index 3b8cc37c0..568585166 100644 --- a/tests/resources/functional/snowflake/core_engine/test_cte/recursive_cte.sql +++ b/tests/resources/functional/snowflake/core_engine/test_cte/recursive_cte.sql @@ -24,4 +24,29 @@ SELECT * FROM employee_hierarchy ORDER BY level, employee_id; --- databricks sql: \ No newline at end of file +-- databricks sql: +/* The following issues were detected: + + *** WITH RECURSIVE IS NOT SUPPORTED *** + WITH RECURSIVE employee_hierarchy AS ( + SELECT + employee_id, + manager_id, + employee_name, + 1 AS level + FROM + employees + WHERE + manager_id IS NULL + UNION ALL + SELECT + e.employee_id, + e.manager_id, + e.employee_name, + eh.level + 1 AS level + FROM + employees e + INNER JOIN + employee_hierarchy eh ON e.manager_id = eh.employee_id + ) + */ \ No newline at end of file From 56d9178755ab44f3e9db7260d8f6a25aa0fdd822 Mon Sep 17 00:00:00 2001 From: "sundar.shankar" Date: Tue, 5 Nov 2024 16:27:54 +0530 Subject: [PATCH 10/12] Fixed review comments --- .../remorph/intermediate/extensions.scala | 5 ++ .../snowflake/SnowflakeAstBuilder.scala | 9 +--- .../snowflake/SnowflakeAstBuilderSpec.scala | 51 +++++++++++++++++++ 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/core/src/main/scala/com/databricks/labs/remorph/intermediate/extensions.scala b/core/src/main/scala/com/databricks/labs/remorph/intermediate/extensions.scala index 94357be00..8328fb290 100644 --- a/core/src/main/scala/com/databricks/labs/remorph/intermediate/extensions.scala +++ b/core/src/main/scala/com/databricks/labs/remorph/intermediate/extensions.scala @@ -37,6 +37,11 @@ case class WithCTE(ctes: Seq[LogicalPlan], query: LogicalPlan) extends RelationC override def children: Seq[LogicalPlan] = ctes :+ query } +case class WithRecursiveCTE(ctes: Seq[LogicalPlan], query: LogicalPlan) extends RelationCommon { + override def output: Seq[Attribute] = query.output + override def children: Seq[LogicalPlan] = ctes :+ query +} + // TODO: (nfx) refactor to align more with catalyst, rename to UnresolvedStar case class Star(objectName: Option[ObjectReference] = None) extends LeafExpression with StarOrAlias { override def dataType: DataType = UnresolvedType diff --git a/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeAstBuilder.scala b/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeAstBuilder.scala index 8b3e31f7b..750c3b09c 100644 --- a/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeAstBuilder.scala +++ b/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeAstBuilder.scala @@ -94,15 +94,10 @@ class SnowflakeAstBuilder(override val vc: SnowflakeVisitorCoordinator) val ctes = vc.relationBuilder.visitMany(ctx.commonTableExpression()) ir.WithCTE(ctes, relation) } else { - ir.UnresolvedCommand( - ruleText = contextText(ctx), - message = "*** WITH RECURSIVE IS NOT SUPPORTED ***", - ruleName = vc.ruleName(ctx), - tokenName = Some(tokenName(ctx.getStart))) + val ctes = vc.relationBuilder.visitMany(ctx.commonTableExpression()) + ir.WithRecursiveCTE(ctes, relation) } - } - } private def buildSetOperator(left: ir.LogicalPlan, ctx: SetOperatorsContext): ir.LogicalPlan = { diff --git a/core/src/test/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeAstBuilderSpec.scala b/core/src/test/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeAstBuilderSpec.scala index 0e90cc487..82becf90e 100644 --- a/core/src/test/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeAstBuilderSpec.scala +++ b/core/src/test/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeAstBuilderSpec.scala @@ -494,5 +494,56 @@ class SnowflakeAstBuilderSpec extends AnyWordSpec with SnowflakeParserTestCommon Project(Filter(namedTable("a"), Equals(Id("b"), Id("$ids"))), Seq(Star()))) } } + + "translate with recursive" should { + """WITH RECURSIVE employee_hierarchy""".stripMargin in { + singleQueryExample( + """WITH RECURSIVE employee_hierarchy AS ( + | SELECT + | employee_id, + | manager_id, + | employee_name, + | 1 AS level + | FROM + | employees + | WHERE + | manager_id IS NULL + | UNION ALL + | SELECT + | e.employee_id, + | e.manager_id, + | e.employee_name, + | eh.level + 1 AS level + | FROM + | employees e + | INNER JOIN + | employee_hierarchy eh ON e.manager_id = eh.employee_id + |) + |SELECT * + |FROM employee_hierarchy + |ORDER BY level, employee_id;""".stripMargin, + WithRecursiveCTE( + Seq( + SubqueryAlias( + Project( + Filter(NamedTable("employees", Map.empty, false), IsNull(Id("manager_id", false))), + Seq( + Id("employee_id", false), + Id("manager_id", false), + Id("employee_name", false), + Alias(Literal(1, IntegerType), Id("level", false)))), + Id("employee_hierarchy", false), + Seq.empty)), + Project( + Sort( + NamedTable("employee_hierarchy", Map.empty, false), + Seq( + SortOrder(Id("level", false), Ascending, NullsLast), + SortOrder(Id("employee_id", false), Ascending, NullsLast)), + false), + Seq(Star(None))))) + } + + } } } From 0302438b605123f858069cf80cbd60c9d11a5dd1 Mon Sep 17 00:00:00 2001 From: "sundar.shankar" Date: Tue, 5 Nov 2024 16:35:00 +0530 Subject: [PATCH 11/12] Fixed review comments --- .../core_engine/test_cte/recursive_cte.sql | 52 ------------------- 1 file changed, 52 deletions(-) delete mode 100644 tests/resources/functional/snowflake/core_engine/test_cte/recursive_cte.sql diff --git a/tests/resources/functional/snowflake/core_engine/test_cte/recursive_cte.sql b/tests/resources/functional/snowflake/core_engine/test_cte/recursive_cte.sql deleted file mode 100644 index 568585166..000000000 --- a/tests/resources/functional/snowflake/core_engine/test_cte/recursive_cte.sql +++ /dev/null @@ -1,52 +0,0 @@ --- snowflake sql: -WITH RECURSIVE employee_hierarchy AS ( - SELECT - employee_id, - manager_id, - employee_name, - 1 AS level - FROM - employees - WHERE - manager_id IS NULL - UNION ALL - SELECT - e.employee_id, - e.manager_id, - e.employee_name, - eh.level + 1 AS level - FROM - employees e - INNER JOIN - employee_hierarchy eh ON e.manager_id = eh.employee_id -) -SELECT * -FROM employee_hierarchy -ORDER BY level, employee_id; - --- databricks sql: -/* The following issues were detected: - - *** WITH RECURSIVE IS NOT SUPPORTED *** - WITH RECURSIVE employee_hierarchy AS ( - SELECT - employee_id, - manager_id, - employee_name, - 1 AS level - FROM - employees - WHERE - manager_id IS NULL - UNION ALL - SELECT - e.employee_id, - e.manager_id, - e.employee_name, - eh.level + 1 AS level - FROM - employees e - INNER JOIN - employee_hierarchy eh ON e.manager_id = eh.employee_id - ) - */ \ No newline at end of file From ce94cd41db32ce222e3759f6d5f18cbdfb9eef5c Mon Sep 17 00:00:00 2001 From: "sundar.shankar" Date: Tue, 5 Nov 2024 16:47:50 +0530 Subject: [PATCH 12/12] Added TODO --- .../labs/remorph/parsers/snowflake/SnowflakeAstBuilder.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeAstBuilder.scala b/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeAstBuilder.scala index 750c3b09c..a228a9f1a 100644 --- a/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeAstBuilder.scala +++ b/core/src/main/scala/com/databricks/labs/remorph/parsers/snowflake/SnowflakeAstBuilder.scala @@ -94,6 +94,7 @@ class SnowflakeAstBuilder(override val vc: SnowflakeVisitorCoordinator) val ctes = vc.relationBuilder.visitMany(ctx.commonTableExpression()) ir.WithCTE(ctes, relation) } else { + // TODO With Recursive CTE are not support by default, will require a custom implementation IR to be redefined val ctes = vc.relationBuilder.visitMany(ctx.commonTableExpression()) ir.WithRecursiveCTE(ctes, relation) }