Skip to content

[SQL][MINOR][Refactor] Refactor on sql/core#22685

Closed
da-liii wants to merge 2 commits intoapache:masterfrom
da-liii:minor/refactor
Closed

[SQL][MINOR][Refactor] Refactor on sql/core#22685
da-liii wants to merge 2 commits intoapache:masterfrom
da-liii:minor/refactor

Conversation

@da-liii
Copy link
Contributor

@da-liii da-liii commented Oct 10, 2018

What changes were proposed in this pull request?

Only minor changes on Scala syntax.

How was this patch tested?

Existing Tests

@SparkQA
Copy link

SparkQA commented Oct 10, 2018

Test build #97189 has finished for PR 22685 at commit 2d0debb.

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

@da-liii da-liii changed the title [SQL][MINOR][Refactor] Refactor sql/core [WIP][SQL][MINOR][Refactor] Refactor on sql/core Oct 10, 2018
Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

Looks mostly style changes. I wouldn't do this since it makes backporting harder. I think it's best to help review and leave some comments for such nits in the future.

@da-liii
Copy link
Contributor Author

da-liii commented Oct 10, 2018

@HyukjinKwon OK, most of changes are related to parens. I will consider to reset it back for backporting friendliness.

@da-liii da-liii changed the title [WIP][SQL][MINOR][Refactor] Refactor on sql/core [SQL][MINOR][Refactor] Refactor on sql/core Oct 10, 2018
@HyukjinKwon
Copy link
Member

I think you're mostly trying to target changes styles. If there is not actual benefit rather then just styles, I wouldn't do this and just help review other PRs.

buildStaticConf("spark.sql.ui.retainedExecutions")
.doc("Number of executions to retain in the Spark UI.")
.intConf
.longConf
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This involves a implicit int2long cast.

val builder = new StringBuilder
val kFields = kExprEnc.schema.map {
case f => s"${f.name}: ${f.dataType.simpleString(2)}"
f => s"${f.name}: ${f.dataType.simpleString(2)}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should not be a partial function!

case 's' =>
// Read StructType for DataFrame
val fields = SerDe.readList(dis, jvmObjectTracker = null).asInstanceOf[Array[Object]]
val fields = SerDe.readList(dis, jvmObjectTracker = null)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

useless asInstanceOf

def createMetric(sc: SparkContext, name: String): SQLMetric = {
val acc = new SQLMetric(SUM_METRIC)
acc.register(sc, name = Some(name), countFailedValues = false)
acc.register(sc, name = Some(name))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

duplicated assignment

dataType: DataType,
inputSchemas: Option[Seq[ScalaReflection.Schema]]): UserDefinedFunction = {
val udf = new UserDefinedFunction(f, dataType, inputSchemas.map(_.map(_.dataType)))
val udf = UserDefinedFunction(f, dataType, inputSchemas.map(_.map(_.dataType)))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

useless new for case class

@da-liii
Copy link
Contributor Author

da-liii commented Oct 10, 2018

@HyukjinKwon Sorry. Happened to find that some code is not elegant according to my taste. I have did not get the fact that massive changes are not good for backporting. As a result, I spent some time trying to make the code better.

I have commented on the most important ones according to my standard. Please review. And the rest, I will revert.

@SparkQA
Copy link

SparkQA commented Oct 10, 2018

Test build #97194 has finished for PR 22685 at commit 52ed24e.

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

Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

It still looks mostly just style changes. Touching multiple files here and there brings backporting overhead in the future (say, this diff will causes some conflicts when we backport some patches into other branches that does not have this change). If the change is not worth enough like just style, I wouldn't go ahead.

There's one legitimate change that might cause a potential actual problem (I commented above), which I wouldn't propose a PR to fix one instance

private val equality = sparkSession.sessionState.conf.resolver

bucketSpec.map { bucket =>
bucketSpec.foreach { bucket =>
Copy link
Member

Choose a reason for hiding this comment

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

Yea, this is legitimate change.

@da-liii
Copy link
Contributor Author

da-liii commented Oct 11, 2018

OK. Nevermind.

@da-liii da-liii closed this Oct 11, 2018
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.

3 participants