forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "[SPARK-42702][SPARK-42623][SQL] Support parameterized query i…
…n subquery and CTE" This reverts commit a780703.
- Loading branch information
1 parent
a780703
commit b36966f
Showing
11 changed files
with
86 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 0 additions & 112 deletions
112
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/parameters.scala
This file was deleted.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/parameters.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.sql.catalyst.expressions | ||
|
||
import org.apache.spark.SparkException | ||
import org.apache.spark.sql.catalyst.analysis.AnalysisErrorAt | ||
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan | ||
import org.apache.spark.sql.catalyst.trees.TreePattern.{PARAMETER, TreePattern} | ||
import org.apache.spark.sql.errors.QueryErrorsBase | ||
import org.apache.spark.sql.types.DataType | ||
|
||
/** | ||
* The expression represents a named parameter that should be replaced by a literal. | ||
* | ||
* @param name The identifier of the parameter without the marker. | ||
*/ | ||
case class Parameter(name: String) extends LeafExpression with Unevaluable { | ||
override lazy val resolved: Boolean = false | ||
|
||
private def unboundError(methodName: String): Nothing = { | ||
throw SparkException.internalError( | ||
s"Cannot call `$methodName()` of the unbound parameter `$name`.") | ||
} | ||
override def dataType: DataType = unboundError("dataType") | ||
override def nullable: Boolean = unboundError("nullable") | ||
|
||
final override val nodePatterns: Seq[TreePattern] = Seq(PARAMETER) | ||
} | ||
|
||
|
||
/** | ||
* Finds all named parameters in the given plan and substitutes them by literals of `args` values. | ||
*/ | ||
object Parameter extends QueryErrorsBase { | ||
def bind(plan: LogicalPlan, args: Map[String, Expression]): LogicalPlan = { | ||
if (!args.isEmpty) { | ||
args.filter(!_._2.isInstanceOf[Literal]).headOption.foreach { case (name, expr) => | ||
expr.failAnalysis( | ||
errorClass = "INVALID_SQL_ARG", | ||
messageParameters = Map("name" -> toSQLId(name))) | ||
} | ||
plan.transformAllExpressionsWithPruning(_.containsPattern(PARAMETER)) { | ||
case Parameter(name) if args.contains(name) => args(name) | ||
} | ||
} else { | ||
plan | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.