Skip to content

Conversation

@ericsahit
Copy link

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.

@ericsahit
Copy link
Author

cc @rxin @gatorsmile @cloud-fan Could you please review this? Thanks!

Copy link
Member

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.

@gatorsmile
Copy link
Member

ok to test

Copy link
Member

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.

Copy link
Author

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!

Copy link
Member

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)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remove this space

Copy link
Member

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.

@SparkQA
Copy link

SparkQA commented Jun 12, 2017

Test build #77918 has started for PR 18268 at commit 8745848.

@SparkQA
Copy link

SparkQA commented Jun 13, 2017

Test build #77965 has started for PR 18268 at commit 9f29f7b.

Copy link
Member

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)
      ...
  }

Copy link
Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about

RESET `special#$!`?

@ericsahit
Copy link
Author

ok, i have fix typo and code stye according to your comments. @gatorsmile @cloud-fan any suggestion would be welcome. Thanks!

Copy link
Contributor

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...

Copy link
Author

@ericsahit ericsahit Jun 13, 2017

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.

Copy link
Contributor

@wzhfy wzhfy Jun 13, 2017

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?

@SparkQA
Copy link

SparkQA commented Jun 13, 2017

Test build #77983 has finished for PR 18268 at commit 00db274.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jun 13, 2017

Test build #77984 has finished for PR 18268 at commit 790608f.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Member

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") {

Copy link
Member

@gatorsmile gatorsmile Jun 14, 2017

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.

Copy link
Contributor

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

Copy link
Author

@ericsahit ericsahit Jun 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, done.

Copy link
Contributor

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!`

Copy link
Author

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.

@SparkQA
Copy link

SparkQA commented Jun 15, 2017

Test build #78106 has finished for PR 18268 at commit 99436d6.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@ericsahit
Copy link
Author

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!")))
Copy link
Contributor

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.

Copy link
Author

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)>

@wzhfy
Copy link
Contributor

wzhfy commented Jun 16, 2017

Hive supports reset multiple keys like: reset config1 config2 or reset config1, config2, should we also support that?

@ericsahit
Copy link
Author

@gatorsmile @cloud-fan , @wzhfy just give an extra propose, should we support reset multiple property?

I make a hive test like:


hive (temp)> set mapreduce.job.reduces=100;
hive (temp)> set mapreduce.job.reduces;
mapreduce.job.reduces=100
hive (temp)> set mapreduce.job.queuename=root.test;
hive (temp)> set mapreduce.job.queuename;
mapreduce.job.queuename=root.test
hive (temp)> reset mapreduce.job.queuename mapreduce.job.reduces;
hive (temp)> set mapreduce.job.queuename;
mapreduce.job.queuename=root.default
hive (temp)> set mapreduce.job.reduces;
mapreduce.job.reduces=-1

@gatorsmile
Copy link
Member

Yes. Please do it.

@gatorsmile
Copy link
Member

ping @ericsahit

@SparkQA
Copy link

SparkQA commented Jun 25, 2017

Test build #78576 has finished for PR 18268 at commit ecc2650.

  • This patch fails to build.
  • This patch merges cleanly.
  • This patch adds no public classes.

@ericsahit
Copy link
Author

@gatorsmile Sorry for the delay, I just add this reset multiple property feature. please review it. Thanks!

And more, fail of unit test seems not related with this patch.

@SparkQA
Copy link

SparkQA commented Jun 25, 2017

Test build #78579 has finished for PR 18268 at commit d8e7106.

  • This patch fails to build.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

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")
Copy link
Contributor

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.

Copy link
Author

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..

Copy link
Contributor

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") {
Copy link
Contributor

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"

Copy link
Author

@ericsahit ericsahit Jun 26, 2017

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

@SparkQA
Copy link

SparkQA commented Jun 26, 2017

Test build #78617 has finished for PR 18268 at commit d8e7106.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jun 26, 2017

Test build #78630 has finished for PR 18268 at commit e4cb39c.

  • This patch fails PySpark pip packaging tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

retest this please

@SparkQA
Copy link

SparkQA commented Jun 26, 2017

Test build #78633 has finished for PR 18268 at commit e4cb39c.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

sparkSession.sessionState.conf.clear()
// "RESET key" clear a specific property.
case Some(key) =>
key.split("\\s+")
Copy link
Member

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` ?

Copy link
Author

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,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the PR #18368

@gatorsmile
Copy link
Member

ping @ericsahit Could you update your PR with extra changes like #18368 ?

@gatorsmile
Copy link
Member

ping @ericsahit

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@asfgit asfgit closed this in 1a4fda8 Jul 19, 2018
zifeif2 pushed a commit to zifeif2/spark that referenced this pull request Nov 22, 2025
Closes apache#17422
Closes apache#17619
Closes apache#18034
Closes apache#18229
Closes apache#18268
Closes apache#17973
Closes apache#18125
Closes apache#18918
Closes apache#19274
Closes apache#19456
Closes apache#19510
Closes apache#19420
Closes apache#20090
Closes apache#20177
Closes apache#20304
Closes apache#20319
Closes apache#20543
Closes apache#20437
Closes apache#21261
Closes apache#21726
Closes apache#14653
Closes apache#13143
Closes apache#17894
Closes apache#19758
Closes apache#12951
Closes apache#17092
Closes apache#21240
Closes apache#16910
Closes apache#12904
Closes apache#21731
Closes apache#21095

Added:
Closes apache#19233
Closes apache#20100
Closes apache#21453
Closes apache#21455
Closes apache#18477

Added:
Closes apache#21812
Closes apache#21787

Author: hyukjinkwon <[email protected]>

Closes apache#21781 from HyukjinKwon/closing-prs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants