cloud-fan commented on code in PR #41568:
URL: https://github.com/apache/spark/pull/41568#discussion_r1234700996
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/parameters.scala:
##########
@@ -71,21 +119,24 @@ object BindParameters extends Rule[LogicalPlan] with
QueryErrorsBase {
plan.resolveOperatorsWithPruning(_.containsPattern(PARAMETERIZED_QUERY)) {
// We should wait for `CTESubstitution` to resolve CTE before binding
parameters, as CTE
// relations are not children of `UnresolvedWith`.
- case p @ ParameterizedQuery(child, args) if
!child.containsPattern(UNRESOLVED_WITH) =>
- args.find(!_._2.isInstanceOf[Literal]).foreach { case (name, expr) =>
- expr.failAnalysis(
- errorClass = "INVALID_SQL_ARG",
- messageParameters = Map("name" -> name))
- }
+ case p @ NameParameterizedQuery(child, args) if
!child.containsPattern(UNRESOLVED_WITH) =>
+ checkArgs(args)
+ val res = bind(child) { case NamedParameter(name) if
args.contains(name) => args(name) }
+ res.copyTagsFrom(p)
+ res
+
+ case p @ PosParameterizedQuery(child, args) if
!child.containsPattern(UNRESOLVED_WITH) =>
+ val indexedArgs = args.zipWithIndex
+ checkArgs(indexedArgs.map(arg => (s"_${arg._2}", arg._1)))
+
+ val positions = scala.collection.mutable.Set.empty[Int]
+ bind(child) { case p @ PosParameter(pos) => positions.add(pos); p }
+ val posToIndex = positions.toSeq.sorted.zipWithIndex.toMap
Review Comment:
not exact match, when the number of parameters is too less.
--
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]