-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-18106][SQL] ANALYZE TABLE should raise a ParseException for invalid option #15640
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
Changes from 1 commit
4819dd1
2a7707e
ec0516b
00b4f54
465f646
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 |
|---|---|---|
|
|
@@ -23,8 +23,8 @@ import org.apache.spark.sql.catalyst.catalog.{BucketSpec, CatalogStorageFormat, | |
| import org.apache.spark.sql.catalyst.parser.ParseException | ||
| import org.apache.spark.sql.catalyst.plans.PlanTest | ||
| import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan | ||
| import org.apache.spark.sql.execution.command.{DescribeFunctionCommand, DescribeTableCommand, | ||
| ShowFunctionsCommand} | ||
| import org.apache.spark.sql.execution.command.{AnalyzeTableCommand, DescribeFunctionCommand, | ||
| DescribeTableCommand, ShowFunctionsCommand} | ||
| import org.apache.spark.sql.execution.datasources.{CreateTable, CreateTempViewUsing} | ||
| import org.apache.spark.sql.internal.{HiveSerDe, SQLConf} | ||
| import org.apache.spark.sql.types.{IntegerType, LongType, StringType, StructType} | ||
|
|
@@ -220,4 +220,12 @@ class SparkSqlParserSuite extends PlanTest { | |
|
|
||
| intercept("explain describe tables x", "Unsupported SQL statement") | ||
| } | ||
|
|
||
| test("SPARK-18106 analyze table") { | ||
|
Contributor
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 are also parse tests for AnalyzeTable in sql/hive/src/test/scala/org/apache/spark/sql/hive/StatisticsSuite.scala
Member
Author
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. Sure.
Member
Author
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. Ur, @srinathshankar . I understand the reason why you put this there, so I looked at the StatisticsSuite.scala in both How do you think about that?
Member
Author
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. If you want, I'll remove the normal cases which raises no exceptions.
Contributor
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. Then maybe you can move those parse tests here ? All I'm suggesting is that the parse tests all be together.
Member
Author
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. Thank you. But, the parse test should be rewritten. Is it okay? Those testcase uses def assertAnalyzeCommand(analyzeCommand: String, c: Class[_]) {
val parsed = spark.sessionState.sqlParser.parsePlan(analyzeCommand)
val operators = parsed.collect {
case a: AnalyzeTableCommand => a
case o => o
}
assert(operators.size === 1)
if (operators(0).getClass() != c) {
fail(
s"""$analyzeCommand expected command: $c, but got ${operators(0)}
|parsed command:
|$parsed
""".stripMargin)
}
}
assertAnalyzeCommand(
"ANALYZE TABLE Table1 COMPUTE STATISTICS",
classOf[AnalyzeTableCommand])
Contributor
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. In my opinion it's fine to rewrite and simplify. If you could do that, that would be great.
Member
Author
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. Yep. I have no objection for that. Actually, I love to do that.
Contributor
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. Lets keep the parsing unit test (this file) and the analyze table integration test separate for now.
Member
Author
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. Thank you for the guide! |
||
| assertEqual("analyze table t compute statistics", | ||
| AnalyzeTableCommand(TableIdentifier("t"), noscan = false)) | ||
| assertEqual("analyze table t compute statistics noscan", | ||
| AnalyzeTableCommand(TableIdentifier("t"), noscan = true)) | ||
| intercept("analyze table t compute statistics xxxx", "Expected `NOSCAN` instead of `xxxx`") | ||
| } | ||
| } | ||
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.
What if partition spec is not null ?
What happens with something like
(Could you add a test for that ?)
Maybe
could be moved to the top ?
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.
Thank you for review and I'll handle that too.
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.
Test case is added.