You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/09/06 19:08:39 UTC
[GitHub] [spark] vitaliili-db commented on a diff in pull request #37621: [SPARK-40185][SQL] Remove column suggestion when the candidate list is empty
vitaliili-db commented on code in PR #37621:
URL: https://github.com/apache/spark/pull/37621#discussion_r964077280
##########
core/src/main/resources/error/error-classes.json:
##########
@@ -415,20 +415,56 @@
},
"UNRESOLVED_COLUMN" : {
"message" : [
- "A column or function parameter with name <objectName> cannot be resolved. Did you mean one of the following? [<objectList>]"
+ "A column or function parameter with name <objectName> cannot be resolved."
],
+ "subClass" : {
+ "GENERIC" : {
Review Comment:
Renamed.
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisErrorSuite.scala:
##########
@@ -117,8 +117,18 @@ class AnalysisErrorSuite extends AnalysisTest {
plan: LogicalPlan,
errorClass: String,
messageParameters: Array[String]): Unit = {
+ errorClassTest(name, plan, errorClass, null, messageParameters)
+ }
+
+ def errorClassTest(
+ name: String,
+ plan: LogicalPlan,
+ errorClass: String,
+ errorSubClass: String,
+ messageParameters: Array[String]): Unit = {
Review Comment:
Done, thank you
##########
sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala:
##########
@@ -322,19 +322,27 @@ class DatasetSuite extends QueryTest
val ds = Seq(("a", 1), ("b", 2), ("c", 3)).toDS()
withSQLConf(SQLConf.SUPPORT_QUOTED_REGEX_COLUMN_NAME.key -> "false") {
- var e = intercept[AnalysisException] {
- ds.select(expr("`(_1)?+.+`").as[Int])
- }
- assert(e.getErrorClass == "UNRESOLVED_COLUMN")
- assert(e.messageParameters.head == "`(_1)?+.+`")
-
- e = intercept[AnalysisException] {
- ds.select(expr("`(_1|_2)`").as[Int])
- }
- assert(e.getErrorClass == "UNRESOLVED_COLUMN")
- assert(e.messageParameters.head == "`(_1|_2)`")
+ checkError(
+ exception = intercept[AnalysisException] {
+ ds.select(expr("`(_1)?+.+`").as[Int])
+ },
+ errorClass = "UNRESOLVED_COLUMN",
+ errorSubClass = Some("WITH_SUGGESTION"),
+ parameters = Map(
+ "objectName" -> "`(_1)?+.+`",
+ "proposal" -> "`_1`, `_2`"))
+
+ checkError(
+ exception = intercept[AnalysisException] {
+ ds.select(expr("`(_1|_2)`").as[Int])
+ },
+ errorClass = "UNRESOLVED_COLUMN",
+ errorSubClass = Some("WITH_SUGGESTION"),
+ parameters = Map(
+ "objectName" -> "`(_1|_2)`",
+ "proposal" -> "`_1`, `_2`"))
- e = intercept[AnalysisException] {
+ var e = intercept[AnalysisException] {
Review Comment:
This error is hard coded, does not have error class yet.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala:
##########
@@ -178,7 +178,10 @@ object Project {
createNewColumn(columnExpr, f.name, f.metadata, Metadata.empty)
} else {
if (columnPath.isEmpty) {
- throw QueryCompilationErrors.unresolvedColumnError(f.name, fields.map(_._1))
+ val candidates = fields.map(_._1)
+ val orderedCandidates =
+ StringUtils.orderStringsBySimilarity(f.name, candidates).take(5)
Review Comment:
Done
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org