Uh oh!
There was an error while loading. Please reload this page.
[SPARK-33441][BUILD] Add unused-imports compilation check and remove all unused-imports - #30351
[SPARK-33441][BUILD] Add unused-imports compilation check and remove all unused-imports#30351LuciferYang wants to merge 23 commits into
Conversation
HyukjinKwon
commented
Nov 12, 2020
@LuciferYang, since you're here, can you see if |
SparkQA
commented
Nov 12, 2020
Kubernetes integration test starting |
SparkQA
commented
Nov 12, 2020
Kubernetes integration test status success |
LuciferYang
commented
Nov 12, 2020
@HyukjinKwon Let me have a try ~ |
@HyukjinKwon Looks like After add After add |
Yeah, we can add it into |
SparkQA
commented
Nov 12, 2020
Test build #130988 has finished for PR 30351 at commit
|
LuciferYang
commented
Nov 12, 2020
Address 986ffe5 add
|
Seems GitHub Action compile with |
SparkQA
commented
Nov 12, 2020
Kubernetes integration test starting |
@HyukjinKwon There are total 505 |
HyukjinKwon
commented
Nov 12, 2020
Yes, GitHub Actions build use SBT with |
HyukjinKwon
commented
Nov 12, 2020
You'll probably have to specify |
LuciferYang
commented
Nov 12, 2020
OK ~ It doesn't look like a minor anymore, It's a little late today in my timezone and I will try to finish the work tomorrow :) |
SparkQA
commented
Nov 12, 2020
Test build #131006 has finished for PR 30351 at commit
|
SparkQA
commented
Nov 12, 2020
Kubernetes integration test status success |
SparkQA
commented
Nov 13, 2020
Test build #131042 has finished for PR 30351 at commit
|
SparkQA
commented
Nov 18, 2020
Test build #131279 has finished for PR 30351 at commit
|
LuciferYang
commented
Nov 18, 2020
SparkQA
commented
Nov 18, 2020
Kubernetes integration test starting |
SparkQA
commented
Nov 18, 2020
Kubernetes integration test status success |
SparkQA
commented
Nov 18, 2020
Test build #131294 has finished for PR 30351 at commit
|
HyukjinKwon
commented
Nov 19, 2020
Okay, this gets conflicted easily. Let's merge this in, @LuciferYang can you resolve the conflicts? |
SparkQA
commented
Nov 19, 2020
Test build #131311 has finished for PR 30351 at commit
|
SparkQA
commented
Nov 19, 2020
Kubernetes integration test starting |
LuciferYang
commented
Nov 19, 2020
@HyukjinKwon done ~ Address 3498654 resolve the conflicts and Address ef2ff08 fix new added |
SparkQA
commented
Nov 19, 2020
Kubernetes integration test status failure |
SparkQA
commented
Nov 19, 2020
Kubernetes integration test starting |
SparkQA
commented
Nov 19, 2020
Kubernetes integration test status success |
HyukjinKwon
commented
Nov 19, 2020
Merged to master. |
SparkQA
commented
Nov 19, 2020
Test build #131315 has finished for PR 30351 at commit
|
LuciferYang
commented
Nov 19, 2020
Thanks for your review ~ @HyukjinKwon@srowen |
MaxGekk
left a comment
There was a problem hiding this comment.
Is dev/scalastyle supposed to catch unused imports?
$ ./dev/scalastyle
Scalastyle checks passed.
$ build/sbt -Phadoop-3.2 -Phive-2.3 -Pyarn -Phadoop-cloud -Phive-thriftserver -Pkubernetes -Pmesos -Phive -Pkinesis-asl -Pspark-ganglia-lgpl test:package streaming-kinesis-asl-assembly/assembly
[error] /Users/maximgekk/proj/show-partitions-exec-v2-test/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala:23:105: Unused import
[error] import org.apache.spark.sql.catalyst.analysis.{ResolvedNamespace, ResolvedPartitionSpec, ResolvedTable, ResolvedView}
[error] ^
[error] /Users/maximgekk/proj/show-partitions-exec-v2-test/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/ShowPartitionsExec.scala:20:29: Unused import
[error] import org.apache.spark.sql.AnalysisException
[error] ^
[error] two errors found
[error] (sql / Compile / compileIncremental) Compilation failed
[error] Total time: 32 s, completed Nov 19, 2020 6:30:02 PM
@MaxGekk use |
@MaxGekk seems no corresponding rule scalastyle-rules |
MaxGekk
commented
Nov 19, 2020
Just in case, Maven doesn't detect unused imports too: |
LuciferYang
commented
Nov 20, 2020
@MaxGekk |
@HyukjinKwon@srowen@MaxGekk do you know how to add maven: sbt: seems need add And only add |
HyukjinKwon
commented
Nov 20, 2020
Doing in SBT side only is fine. The purpose of doing this is to catch the unused imports in PRs. |
| <commons.collections.version>3.2.2</commons.collections.version> | ||
| <scala.version>2.12.10</scala.version> | ||
| <scala.binary.version>2.12</scala.binary.version> | ||
| <scalac.arg.unused-imports>-Ywarn-unused-import</scalac.arg.unused-imports> |
There was a problem hiding this comment.
Shall we just move it to SparkBuild.scala and let Maven doesn't care about that?
There was a problem hiding this comment.
There should be only some warnings when maven build now, seems that @MaxGekk wants maven check it as error too?
There was a problem hiding this comment.
If it's easy to make both Maven and SBT build throw an error, it's fine. If that's difficult, let's move it to SparkBuild.scala, and make it SBT specific.
There was a problem hiding this comment.
Shall we just move it to SparkBuild.scala and let Maven doesn't care about that?
It may be useful for Maven, it can also help Maven users to check this although it is only warnings with maven build
There was a problem hiding this comment.
@HyukjinKwon Is it necessary for us to add more compiler checking further? like unused-locals?
There was a problem hiding this comment.
We can give a shot. Are they a lot of instances of unused-locals to fix? If there are too many, I think we should collect some more feedback from other committers because it makes more difficult to maintain the codes (e.g., reverting and backporting).
There was a problem hiding this comment.
OK ~ I'll collect the details of the issue like unused-locals first, then file a new Jira for tracking and discussion. thanks @HyukjinKwon
What changes were proposed in this pull request?
This pr add a new Scala compile arg to
pom.xmlto defense against new unused imports:-Ywarn-unused-importfor Scala 2.12-Wconf:cat=unused-imports:efor Scala 2.13The other fIles change are remove all unused imports in Spark code
Why are the changes needed?
Cleanup code and add guarantee to defense against new unused imports
Does this PR introduce any user-facing change?
No
How was this patch tested?
Pass the Jenkins or GitHub Action