-
Notifications
You must be signed in to change notification settings - Fork 33
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
Support table identifier contains dot with backticks #768
Changes from all commits
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 |
---|---|---|
|
@@ -37,13 +37,26 @@ class PPLLogicalPlanBasicQueriesTranslatorTestSuite | |
thrown.getMessage === "Invalid table name: t.b.c.d Syntax: [ database_name. ] table_name") | ||
} | ||
|
||
test("test describe with backticks") { | ||
val context = new CatalystPlanContext | ||
val logPlan = | ||
planTransformer.visit(plan(pplParser, "describe t.b.`c.d`"), context) | ||
|
||
val expectedPlan = DescribeTableCommand( | ||
TableIdentifier("c.d", Option("b"), Option("t")), | ||
Map.empty[String, String].empty, | ||
isExtended = true, | ||
output = DescribeRelation.getOutputAttrs) | ||
comparePlans(expectedPlan, logPlan, false) | ||
} | ||
|
||
test("test describe FQN table clause") { | ||
val context = new CatalystPlanContext | ||
val logPlan = | ||
planTransformer.visit(plan(pplParser, "describe schema.default.http_logs"), context) | ||
planTransformer.visit(plan(pplParser, "describe catalog.schema.http_logs"), context) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR also fixes a bug of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @LantaoJin nice catch - thanks |
||
|
||
val expectedPlan = DescribeTableCommand( | ||
TableIdentifier("http_logs", Option("schema"), Option("default")), | ||
TableIdentifier("http_logs", Option("schema"), Option("catalog")), | ||
Map.empty[String, String].empty, | ||
isExtended = true, | ||
output = DescribeRelation.getOutputAttrs) | ||
|
@@ -64,10 +77,10 @@ class PPLLogicalPlanBasicQueriesTranslatorTestSuite | |
|
||
test("test FQN table describe table clause") { | ||
val context = new CatalystPlanContext | ||
val logPlan = planTransformer.visit(plan(pplParser, "describe catalog.t"), context) | ||
val logPlan = planTransformer.visit(plan(pplParser, "describe schema.t"), context) | ||
|
||
val expectedPlan = DescribeTableCommand( | ||
TableIdentifier("t", Option("catalog")), | ||
TableIdentifier("t", Option("schema")), | ||
Map.empty[String, String].empty, | ||
isExtended = true, | ||
output = DescribeRelation.getOutputAttrs) | ||
|
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.
These are the key lines to fix the bug of "dot in backticks"
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.
Replace simple string manipulation with building a Spark
TableIdentifier
. This fixing not only could identify a valid patterncatalog.schema.`table.name`
, but also could identify an invalid patterncatalog.schema.table.name
(more than 3 parts and without backticks)