[GitHub] [spark] MaxGekk commented on a diff in pull request #42752: [SPARK-45033][SQL] Support maps by parameterized `sql()`

2023-09-03 Thread via GitHub


MaxGekk commented on code in PR #42752:
URL: https://github.com/apache/spark/pull/42752#discussion_r1314453024


##
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/parameters.scala:
##
@@ -96,7 +96,11 @@ case class PosParameterizedQuery(child: LogicalPlan, args: 
Array[Expression])
  */
 object BindParameters extends Rule[LogicalPlan] with QueryErrorsBase {
   private def checkArgs(args: Iterable[(String, Expression)]): Unit = {
-args.find(!_._2.isInstanceOf[Literal]).foreach { case (name, expr) =>
+def isNotAllowed(expr: Expression): Boolean = expr.exists {
+  case _: Literal | _: CreateArray | _: MapFromArrays | _: CreateMap => 
false

Review Comment:
   ok. How about to support `MapFromEntries` as well? And maybe 
`CreateNamedStruct`? 



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] MaxGekk commented on a diff in pull request #42752: [SPARK-45033][SQL] Support maps by parameterized `sql()`

2023-09-03 Thread via GitHub


MaxGekk commented on code in PR #42752:
URL: https://github.com/apache/spark/pull/42752#discussion_r1314446198


##
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/parameters.scala:
##
@@ -96,7 +96,11 @@ case class PosParameterizedQuery(child: LogicalPlan, args: 
Array[Expression])
  */
 object BindParameters extends Rule[LogicalPlan] with QueryErrorsBase {
   private def checkArgs(args: Iterable[(String, Expression)]): Unit = {
-args.find(!_._2.isInstanceOf[Literal]).foreach { case (name, expr) =>
+def isNotAllowed(expr: Expression): Boolean = expr.exists {
+  case _: Literal | _: CreateArray | _: MapFromArrays | _: CreateMap => 
false

Review Comment:
   Let me add an negative test with an deep nested prohibited expression.



##
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/parameters.scala:
##
@@ -96,7 +96,11 @@ case class PosParameterizedQuery(child: LogicalPlan, args: 
Array[Expression])
  */
 object BindParameters extends Rule[LogicalPlan] with QueryErrorsBase {
   private def checkArgs(args: Iterable[(String, Expression)]): Unit = {
-args.find(!_._2.isInstanceOf[Literal]).foreach { case (name, expr) =>
+def isNotAllowed(expr: Expression): Boolean = expr.exists {
+  case _: Literal | _: CreateArray | _: MapFromArrays | _: CreateMap => 
false

Review Comment:
   Let me add an negative test with a deep nested prohibited expression.



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] MaxGekk commented on a diff in pull request #42752: [SPARK-45033][SQL] Support maps by parameterized `sql()`

2023-09-03 Thread via GitHub


MaxGekk commented on code in PR #42752:
URL: https://github.com/apache/spark/pull/42752#discussion_r131739


##
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/parameters.scala:
##
@@ -96,7 +96,11 @@ case class PosParameterizedQuery(child: LogicalPlan, args: 
Array[Expression])
  */
 object BindParameters extends Rule[LogicalPlan] with QueryErrorsBase {
   private def checkArgs(args: Iterable[(String, Expression)]): Unit = {
-args.find(!_._2.isInstanceOf[Literal]).foreach { case (name, expr) =>
+def isNotAllowed(expr: Expression): Boolean = expr.exists {
+  case _: Literal | _: CreateArray | _: MapFromArrays | _: CreateMap => 
false

Review Comment:
   `_.exists` checks the children recursively, doesn't it? So, we allow mix of 
arrays, maps and literals.  



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org