-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-39783][SQL] Quote qualifiedName to fix backticks for column candidates in error messages #38256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-39783][SQL] Quote qualifiedName to fix backticks for column candidates in error messages #38256
Changes from 1 commit
f59e9df
1d8a919
dc80706
cef2711
f919303
b9c9907
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -876,6 +876,24 @@ class AnalysisErrorSuite extends AnalysisTest { | |
| "[`a`, `b`, `c`, `d`, `e`]" | ||
| :: Nil) | ||
|
|
||
| errorTest( | ||
|
||
| "SPARK-39783: backticks in error message for candidate column with dots", | ||
| // This selects a column that does not exist, | ||
| // the error message suggest the existing column with correct backticks | ||
| testRelation6.select($"`the`.`id`"), | ||
| "[UNRESOLVED_COLUMN.WITH_SUGGESTION] A column or function parameter with name `the`.`id` " + | ||
| "cannot be resolved. Did you mean one of the following? [`the.id`]" | ||
| :: Nil) | ||
|
|
||
| errorTest( | ||
| "SPARK-39783: backticks in error message for candidate struct column", | ||
| // This selects a column that does not exist, | ||
| // the error message suggest the existing column with correct backticks | ||
| nestedRelation2.select($"`top.aField`"), | ||
| "[UNRESOLVED_COLUMN.WITH_SUGGESTION] A column or function parameter with name `top.aField` " + | ||
| "cannot be resolved. Did you mean one of the following? [`top`]" | ||
| :: Nil) | ||
|
|
||
| test("SPARK-35080: Unsupported correlated equality predicates in subquery") { | ||
| val a = AttributeReference("a", IntegerType)() | ||
| val b = AttributeReference("b", IntegerType)() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1992,6 +1992,33 @@ class DatasetSuite extends QueryTest | |
| } | ||
| } | ||
|
|
||
| test("SPARK-39783: Fix error messages for columns with dots/periods") { | ||
| forAll(dotColumnTestModes) { (caseSensitive, colName) => | ||
| val ds = Seq(SpecialCharClass("1", "2")).toDS | ||
| withSQLConf(SQLConf.CASE_SENSITIVE.key -> caseSensitive) { | ||
| val errorMsg = intercept[AnalysisException] { | ||
| // Note: ds(colName) has different semantics than ds.select(colName) | ||
| ds.select(colName) | ||
| } | ||
| assert(errorMsg.getMessage.contains( | ||
|
||
| s"A column or function parameter with name `${colName.replace(".", "`.`")}` " + | ||
| s"cannot be resolved. Did you mean one of the following? [`field.1`, `field 2`]")) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-39783: backticks in error message for candidate column with dots") { | ||
| checkError( | ||
| exception = intercept[AnalysisException] { | ||
| Seq(0).toDF("the.id").select("the.id") | ||
| }, | ||
| errorClass = "UNRESOLVED_COLUMN.WITH_SUGGESTION", | ||
| sqlState = None, | ||
| parameters = Map( | ||
| "objectName" -> "`the`.`id`", | ||
| "proposal" -> "`the.id`")) | ||
| } | ||
|
|
||
| test("groupBy.as") { | ||
| val df1 = Seq(DoubleData(1, "one"), DoubleData(2, "two"), DoubleData(3, "three")).toDS() | ||
| .repartition($"id").sortWithinPartitions("id") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.