-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Build: Apply spotless for scala code #8023
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
base: main
Are you sure you want to change the base?
Conversation
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| align = 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.
This is modified from spark
| } | ||
| danglingParentheses.preset = false | ||
| docstrings.style = Asterisk | ||
| maxColumn = 100 |
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.
Set to 100 to align java code.
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.
just curious, what's the default value? For Java the default is mandated by the Google Java Format and set to 100
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.
The default is 80, docs at here: https://scalameta.org/scalafmt/docs/configuration.html#maxcolumn
.../scala/org/apache/spark/sql/catalyst/parser/extensions/IcebergSparkSqlExtensionsParser.scala
Outdated
Show resolved
Hide resolved
...-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/MergeIntoExec.scala
Outdated
Show resolved
Hide resolved
...sions/src/main/scala/org/apache/spark/sql/catalyst/analysis/AssignmentAlignmentSupport.scala
Outdated
Show resolved
Hide resolved
|
@Fokko are we going to force styles on scala as well? not sure why this isn't done when enforcing styles on java. |
|
Also cc @jackye1995 @amogh-jahagirdar who have disscuessed this at #6736 |
|
@ConeyLiu I think this is a great topic to mention on the DEV mailist list & Iceberg Sync, so that people are aware about this effort |
|
Thanks @nastra, raised the discussion at the dev mail list. |
|
LGTM now, I'd suggest let's get this style in early. |
|
Just linking the conclusion here as I was searching for it. |
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions. |
|
This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time. |
|
@ConeyLiu are you interested in continuing work on this? |
|
Sure, I will rebase it these days. |
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions. |
|
|
||
| version = 3.9.7 | ||
|
|
||
| align = 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.
I haven't checked but are these settings resulting in code style that it very close to the Apache Spark codebase?
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.
Yes, the spark config is here: https://github.com/apache/spark/blob/master/dev/.scalafmt.conf.
The differences:
# spark
maxColumn = 98
version = 3.8.6
# iceberg
docstrings.wrap = false # suggestion from comments
maxColumn = 100
rewrite.rules = [Imports]
version = 3.9.7
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.
for learning, why do we deviate for [Imports]
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.
Removed the [Imports] to keep it aligned with Spark. We could add the following if needed:
// https://scalameta.org/scalafmt/docs/configuration.html#imports
rewrite.rules = [Imports]
rewrite.imports.sort = original
| danglingParentheses.preset = false | ||
| docstrings.style = Asterisk | ||
| docstrings.wrap = false | ||
| maxColumn = 100 |
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.
given that we can fully control this (and since we're deviating from Spark anyway) I think it's fine to set this to 120 or 140 even. Let's see what others think.
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.
this LGTM, I think we can discuss what the final maxColumn value should be (e.g. 120 or 140 instead of 100).
Also it would be good to update https://github.com/apache/iceberg/blob/8e897f1b68c38c6352f23d636c320e3754d58eef/site/docs/contribute.md#setting-up-ide-and-code-style and mention how to set up IntelliJ with Scalafmt so that formatting inside IntelliJ produces the same formatting results across cmd line (./gradlew spotlessApply) and the IDE
|
@ConeyLiu could you please raise awareness about this on the DEV mailing list so that people have a chance to review this? |
@nastra Does this need a separate commit or rebased into the first commit 'Add scalafmt and config for spotless' |
Done it. |
I think adding this into the first commit should be fine |
|
|
||
| version = 3.9.7 | ||
|
|
||
| align = 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.
for learning, why do we deviate for [Imports]
| output: Seq[Attribute], | ||
| procedure: Procedure, | ||
| input: InternalRow) extends LeafV2CommandExec { | ||
| case class CallExec(output: Seq[Attribute], procedure: Procedure, input: InternalRow) |
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: can we keep the old one to be more like Spark and be more readable (or does it violate scalafmt because of maxColumns?)
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.
| import scala.jdk.CollectionConverters._ | ||
|
|
||
| class IcebergSparkSqlExtensionsParser(delegate: ParserInterface) extends ParserInterface with ExtendedParser { | ||
| class IcebergSparkSqlExtensionsParser(delegate: ParserInterface) |
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.
The import org.apache.iceberg.spark.procedures.SparkProcedures is not used in this class. Should it be removed by spotless?
|
@singhpk234 Based on the issue and PR in Spotless, the unused imports aren’t handled. We need a separate Scalafix rule to take care of that. |

Closes #7695.