-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-21054] [SQL] Reset Command support reset specific property. #18268
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
Conversation
|
cc @rxin @gatorsmile @cloud-fan Could you please review this? Thanks! |
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.
No need to mention Hive here. Just need to explain the semantics.
|
ok to test |
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.
You can use map to shorten it to a single line.
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.
Have been fixed typo except here, @gatorsmile could you please explain a little more? Thanks!
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.
uh... This is a String. Then, we just need to shorten it to a single line
if (raw.nonEmpty) ResetCommand(Some(raw.trim)) else ResetCommand(None)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.
Nit: remove this space
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.
Nit: Just use a few lines to implement logics here. No need to add the extra function.
|
Test build #77918 has started for PR 18268 at commit |
|
Test build #77965 has started for PR 18268 at commit |
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.
Let us combine the three newly added test cases with the existing ones. For example,
Seq("reset", s"reset ${SQLConf.OPTIMIZER_MAX_ITERATIONS.key}").foreach { cmd =>
test(s"$cmd - internal conf") {
...
sql(cmd)
...
}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.
After done this, building threw SQLConfSuite is not a test, maybe this style does not work. @gatorsmile
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 about
RESET `special#$!`?
|
ok, i have fix typo and code stye according to your comments. @gatorsmile @cloud-fan any suggestion would be welcome. Thanks! |
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.
actually I was asking about what's hive's behavior for this case...
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.
you mean there has special character in property name? Hive will also take this special#$! as a property name, play same behavior with SparkSQL.
Internally it take rest of command part as property name.
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.
Internally it take rest of command part as property name.
What if there's a space or other punctuation? e.g.reset prop1 prop2;. Hive treats it like one property, two properties, or throws error?
|
Test build #77983 has finished for PR 18268 at commit
|
|
Test build #77984 has finished for PR 18268 at commit
|
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(s"reset - user-defined conf $resetCmd") {
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.
Please do the same for the others.
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.
+1, otherwise we will have tests with same name
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.
OK, done.
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.
can we add a test for
reset `#a!`
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.
ok, now added one plus sql-parse test for reset special character.
|
Test build #78106 has finished for PR 18268 at commit
|
|
cc @gatorsmile @cloud-fan thanks for reviewing. Any extra suggestion would be welcome |
| test("reset") { | ||
| assertEqual("reset", ResetCommand(None)) | ||
| assertEqual("reset spark.test.property", ResetCommand(Some("spark.test.property"))) | ||
| assertEqual("reset #$a!", ResetCommand(Some("#$a!"))) |
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.
can we check hive's behavior? I think special chars are not allowed in config name and parser should throw exception for this case.
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.
Hive 2.1.1 just play the but same behavior. I thought it is due to hardly define what is normal property as user can define property as they wish.
Hive case:
hive (temp)> set #$!@=1024;
hive (temp)> set #$!@;
#$!@=1024
hive (temp)>
|
Hive supports reset multiple keys like: |
|
@gatorsmile @cloud-fan , @wzhfy just give an extra propose, should we support reset multiple property? I make a hive test like: |
|
Yes. Please do it. |
|
ping @ericsahit |
|
Test build #78576 has finished for PR 18268 at commit
|
|
@gatorsmile Sorry for the delay, I just add this And more, fail of unit test seems not related with this patch. |
|
Test build #78579 has finished for PR 18268 at commit
|
|
retest this please |
| assert(spark.conf.get(SQLConf.GROUP_BY_ORDINAL) === true) | ||
| assert(sql(s"set").where(s"key = '${SQLConf.GROUP_BY_ORDINAL.key}'").count() == 0) | ||
| } finally { | ||
| sql(s"set ${SQLConf.GROUP_BY_ORDINAL}=$original") |
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.
not introduced in this PR, but we don't need to do this as we call spark.sessionState.conf.clear() at the beginning.
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.
Would you mean it is a duplicated clean action? I suppose the purpose is to prevent impact of other tests..
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 this is OK. After clear(), original gets the default value of the config, so here it wants to keep the default value unchanged.
| } finally { | ||
| sql(s"set ${SQLConf.GROUP_BY_ORDINAL}=$original") | ||
| Seq("reset", s"reset ${SQLConf.GROUP_BY_ORDINAL.key}").foreach { resetCmd => | ||
| test(s"reset - public conf $resetCmd") { |
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.
nit: seems better to make the test name s"$resetCmd - public conf"
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.
done, sounds like a more reasonable name
|
Test build #78617 has finished for PR 18268 at commit
|
|
Test build #78630 has finished for PR 18268 at commit
|
|
retest this please |
|
Test build #78633 has finished for PR 18268 at commit
|
| sparkSession.sessionState.conf.clear() | ||
| // "RESET key" clear a specific property. | ||
| case Some(key) => | ||
| key.split("\\s+") |
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 happened if the space is part of the property key? For example,
RESET `a b` `c d` ?
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.
OK, i plan adding Quoted Identifiers support for such special situation, after all Quote symbol will be the only special delimiter. final use case like this:
spark-sql> set a b=1;
key value
a b 1
Time taken: 0.018 seconds, Fetched 1 row(s)
spark-sql> set c d=2;
key value
c d 2
Time taken: 0.018 seconds, Fetched 1 row(s)
spark-sql> reset a b c d;
Time taken: 0.01 seconds
spark-sql> set a b;
key value
a b 1
spark-sql> reset `a b` `c d`;
Time taken: 0.01 seconds
spark-sql> set a b;
key value
a b <undefined>
Time taken: 0.016 seconds, Fetched 1 row(s)
spark-sql> set c d;
key value
c d <undefined>
spark-sql> reset `a b;
Error in query: Invalid usage of '`' in expression;
I though we should open another issue,
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.
See the PR #18368
|
ping @ericsahit Could you update your PR with extra changes like #18368 ? |
|
ping @ericsahit |
|
Can one of the admins verify this patch? |
What changes were proposed in this pull request?
Reset Command support reset specific property to default value like
reset spark.test.property.Hive 2.1.1 (HIVE-14418) support Reset Command for specific property like
reset spark.test.property, which will throw error in SparkSQL.Compatibility will lower the cost for transferring SQL in production from Hive to SparkSQL.
How was this patch tested?
Add unit tests.
Please review http://spark.apache.org/contributing.html before opening a pull request.