ganeshashree commented on code in PR #57559:
URL: https://github.com/apache/spark/pull/57559#discussion_r3710653623
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala:
##########
@@ -3255,6 +3257,91 @@ class AstBuilder extends DataTypeAstBuilder
mayApplyAliasPlan(unnest.tableAlias, generate)
}
+ /**
+ * Create a plan for the SQL:2016 `JSON_TABLE` table-valued function. This
builds a
+ * [[Generate]] over the [[JsonTable]] generator (reusing the existing
Generate operator), so a
+ * downstream `SELECT` sees one output column per COLUMNS entry.
+ */
+ override def visitJsonTableRelation(
+ ctx: JsonTableRelationContext): LogicalPlan = withOrigin(ctx) {
+ val jt = ctx.jsonTable
+ val jsonExpr = expression(jt.jsonExpr)
+ val rowPath = string(visitStringLit(jt.rowPath))
+
+ val columns = jt.jsonTableColumn.asScala.map(buildJsonTableColumn).toSeq
+ // Column names must be unique within a single JSON_TABLE.
+ val duplicate =
columns.groupBy(_.name.toLowerCase(Locale.ROOT)).collectFirst {
Review Comment:
Fixed. Normalization is now conditional on `conf.caseSensitiveAnalysis`,
mirroring the partition-spec check at AstBuilder.scala:1567. Added duplicate
column name detection follows spark.sql.caseSensitive": mixed-case `id`/`ID` is
distinct when case-sensitive and a duplicate otherwise, and an exact-case
duplicate is still rejected in both modes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]