Skip to content

Conversation

@ouyangxiaochen
Copy link

@ouyangxiaochen ouyangxiaochen commented Apr 13, 2017

What changes were proposed in this pull request?

val and var should strictly follow the Scala syntax

How was this patch tested?

manual test and exisiting test cases

@gatorsmile
Copy link
Member

ok to test

private[hive] object SparkSQLCLIDriver extends Logging {
private var prompt = "spark-sql"
private var continuedPrompt = "".padTo(prompt.length, ' ')
private val prompt = "spark-sql"
Copy link
Member

Choose a reason for hiding this comment

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

This is very old code. Looks this change is okay. cc @liancheng

@HyukjinKwon
Copy link
Member

It is too trivial as a separate PR and I guess we don't need a JIRA for this change. I think we should find the similar instances at least (I don't think we want swarming PRs fixing such things). Also, I think we can fold #17629 into this here.

@viirya
Copy link
Member

viirya commented Apr 13, 2017

It's always good to merge many such changes together into one single PR.

@SparkQA
Copy link

SparkQA commented Apr 13, 2017

Test build #75759 has finished for PR 17628 at commit 32b12a0.

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

@ouyangxiaochen
Copy link
Author

OK, I'll merge such changes together into this PR.

@SparkQA
Copy link

SparkQA commented Apr 13, 2017

Test build #75762 has started for PR 17628 at commit cef0405.

@ouyangxiaochen ouyangxiaochen changed the title [SPARK-20316][SQL] val and var should strictly follow the Scala syntax [SPARK-20316][SQL] Variable and Method should strictly follow the Scala syntax Apr 13, 2017
@srowen
Copy link
Member

srowen commented Apr 13, 2017

I would support this but only if we try to fix all such instances. The val/var changes has some value. However you're also removing 'return' and while that's probably OK as cleanup it's not actually improving much, so am not sure I'd do that.

@ouyangxiaochen
Copy link
Author

ouyangxiaochen commented Apr 13, 2017

This is a very heavy task. So far, I found a problem with this when I was reading SparkSQL source code.
So, whether we need to merge to the master or not firstly? @srowen @viirya
As for the keyword "return", I found that there are so many scala methods use this keyword. So, this problem can be reverted to the origin.

@srowen
Copy link
Member

srowen commented Apr 13, 2017

Yeah, I'm surprised IntelliJ doesn't have an inspection for it. It's otherwise quite hard to find instances that can be changed.

I would look for instances of var foo = "string" as these are often instances where someone meant to declare a constant. There are about 100 of those. If you scan those and address any issues you see, that's a pretty good effort.

IntelliJ can find all the return instances, and there are 39 of them. I'm kind of neutral on cleaning that up, but it would be nice. They occur in places that don't seem likely to cause merge conflicts. Maybe OK to finally touch it up, OK.

@SparkQA
Copy link

SparkQA commented Apr 13, 2017

Test build #75773 has finished for PR 17628 at commit b259471.

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

@ouyangxiaochen
Copy link
Author

I tried to serach the instance of var foo = "string" with the RegEx var [a-z|A-Z] = "* in whole project and there are 740 of them. The usage of them are almost reasonable.
As @viirya commented above, this is very old code. maybe no committer attention it . @srowen

@srowen
Copy link
Member

srowen commented Apr 13, 2017

(You're matching no quotes. Match at least one. It will give you a smaller set to review.)

@ouyangxiaochen
Copy link
Author

OK, I will work on this again, Thanks.

@ouyangxiaochen
Copy link
Author

I serached the instance of var foo = "string" with the RegEx \s*var [a-z|A-Z]* = "*" in whole project and there are 31 of them. The usage of them are almost reasonable except the file SparkSQLCLIDriver.
@srowen cc

@ouyangxiaochen ouyangxiaochen changed the title [SPARK-20316][SQL] Variable and Method should strictly follow the Scala syntax [SPARK-20316][SQL] Val and Var should strictly follow the Scala syntax Apr 14, 2017
@viirya
Copy link
Member

viirya commented Apr 14, 2017

I will be surprised if we find much more of this in current branch. :-)

@srowen
Copy link
Member

srowen commented Apr 14, 2017

@ouyangxiaochen that still isn't the right regex. Maybe there are no other instances but I'd ask for a minimal effort to find similar instances

@ouyangxiaochen
Copy link
Author

@srowen Do u mean that my regex can not match all variable name? because scala's variable name can be consisted with letter|digital|_|$? I serached the instances of var foo="string" with new regex \s*var [a-z|A-Z|$|_]* = "*" and found 33 of them. Maybe really there are no other instances.

@srowen
Copy link
Member

srowen commented Apr 14, 2017

"*" does not mean what you intend -- you mean ".*" at least, among other things. It's maybe not worth pursuing further, but that's the kind of quick check I'd expect when proposing to adjust one small instance of something.

@ouyangxiaochen
Copy link
Author

OK, I got it.

@srowen
Copy link
Member

srowen commented Apr 15, 2017

Merged to master

@ouyangxiaochen ouyangxiaochen deleted the spark-413 branch July 7, 2018 13:37
peter-toth pushed a commit to peter-toth/spark that referenced this pull request Oct 6, 2018
## What changes were proposed in this pull request?

val and var should strictly follow the Scala syntax

## How was this patch tested?

manual test and exisiting test cases

Author: ouyangxiaochen <[email protected]>

Closes apache#17628 from ouyangxiaochen/spark-413.
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