-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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-17832][SQL] TableIdentifier.quotedString creates un-parseable names when name contains a backtick #15403
Conversation
Besides, we have similar problem in |
Test build #66576 has finished for PR 15403 at commit
|
} | ||
|
||
def unquotedString: String = { | ||
if (database.isDefined) s"${database.get}.$identifier" else identifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep unquotedString
this as it is. That gives some a more readable (less parseable) version of the identifier. I just added an example with unquotedIdentifier
to show that there was no way to get a parseable string from the table identifier.
|
||
test("SPARK-17832 table identifier - contains backtick") { | ||
val complexName = TableIdentifier("`weird`table`name", Some("`d`b`1")) | ||
assert(TableIdentifier("`weird`table`name", Some("`d`b`1")) === |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use complexName? Why create the identifier twice?
@jiangxb1987 This looks pretty good. What is the problem |
@hvanhovell nvm about the |
Test build #66596 has finished for PR 15403 at commit
|
LGTM - merging to master/2.0. Thanks! |
…names when name contains a backtick ## What changes were proposed in this pull request? The `quotedString` method in `TableIdentifier` and `FunctionIdentifier` produce an illegal (un-parseable) name when the name contains a backtick. For example: ``` import org.apache.spark.sql.catalyst.parser.CatalystSqlParser._ import org.apache.spark.sql.catalyst.TableIdentifier import org.apache.spark.sql.catalyst.analysis.UnresolvedAttribute val complexName = TableIdentifier("`weird`table`name", Some("`d`b`1")) parseTableIdentifier(complexName.unquotedString) // Does not work parseTableIdentifier(complexName.quotedString) // Does not work parseExpression(complexName.unquotedString) // Does not work parseExpression(complexName.quotedString) // Does not work ``` We should handle the backtick properly to make `quotedString` parseable. ## How was this patch tested? Add new testcases in `TableIdentifierParserSuite` and `ExpressionParserSuite`. Author: jiangxingbo <jiangxb1987@gmail.com> Closes #15403 from jiangxb1987/backtick. (cherry picked from commit 26fbca4) Signed-off-by: Herman van Hovell <hvanhovell@databricks.com>
…names when name contains a backtick ## What changes were proposed in this pull request? The `quotedString` method in `TableIdentifier` and `FunctionIdentifier` produce an illegal (un-parseable) name when the name contains a backtick. For example: ``` import org.apache.spark.sql.catalyst.parser.CatalystSqlParser._ import org.apache.spark.sql.catalyst.TableIdentifier import org.apache.spark.sql.catalyst.analysis.UnresolvedAttribute val complexName = TableIdentifier("`weird`table`name", Some("`d`b`1")) parseTableIdentifier(complexName.unquotedString) // Does not work parseTableIdentifier(complexName.quotedString) // Does not work parseExpression(complexName.unquotedString) // Does not work parseExpression(complexName.quotedString) // Does not work ``` We should handle the backtick properly to make `quotedString` parseable. ## How was this patch tested? Add new testcases in `TableIdentifierParserSuite` and `ExpressionParserSuite`. Author: jiangxingbo <jiangxb1987@gmail.com> Closes apache#15403 from jiangxb1987/backtick.
What changes were proposed in this pull request?
The
quotedString
method inTableIdentifier
andFunctionIdentifier
produce an illegal (un-parseable) name when the name contains a backtick. For example:We should handle the backtick properly to make
quotedString
parseable.How was this patch tested?
Add new testcases in
TableIdentifierParserSuite
andExpressionParserSuite
.