Skip to content

Conversation

@ConeyLiu
Copy link
Contributor

@ConeyLiu ConeyLiu commented Jul 9, 2023

Closes #7695.

# specific language governing permissions and limitations
# under the License.

align = none
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 is modified from spark

}
danglingParentheses.preset = false
docstrings.style = Asterisk
maxColumn = 100
Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zinking
Copy link
Contributor

zinking commented Jul 12, 2023

@Fokko are we going to force styles on scala as well? not sure why this isn't done when enforcing styles on java.
if the answer is yes, guess we need to do this early instead of late.

@ConeyLiu
Copy link
Contributor Author

Hi, @nastra @zinking @Fokko would you mind taking another look at this? Thanks in advance.

@ConeyLiu
Copy link
Contributor Author

Also cc @jackye1995 @amogh-jahagirdar who have disscuessed this at #6736

@nastra
Copy link
Contributor

nastra commented Jul 18, 2023

@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

@ConeyLiu
Copy link
Contributor Author

Thanks @nastra, raised the discussion at the dev mail list.

@zinking
Copy link
Contributor

zinking commented Jul 19, 2023

LGTM now, I'd suggest let's get this style in early.

@ajantha-bhat
Copy link
Member

Just linking the conclusion here as I was searching for it.
https://lists.apache.org/thread/sv70lr0bwl9jmxtzvho2ml5xcrcpzf3b

@github-actions
Copy link

github-actions bot commented Sep 6, 2024

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.

@github-actions github-actions bot added the stale label Sep 6, 2024
@github-actions
Copy link

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.

@github-actions github-actions bot closed this Sep 19, 2024
@nastra
Copy link
Contributor

nastra commented May 14, 2025

@ConeyLiu are you interested in continuing work on this?

@nastra nastra reopened this May 14, 2025
@github-actions github-actions bot removed the stale label May 15, 2025
@ConeyLiu
Copy link
Contributor Author

Sure, I will rebase it these days.

@github-actions
Copy link

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

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?

Copy link
Contributor Author

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

Copy link
Member

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]

Copy link
Contributor Author

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

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.

Copy link
Contributor

@nastra nastra left a 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

@nastra nastra requested a review from aokolnychyi June 24, 2025 07:27
@nastra
Copy link
Contributor

nastra commented Jun 24, 2025

@ConeyLiu could you please raise awareness about this on the DEV mailing list so that people have a chance to review this?

@ConeyLiu
Copy link
Contributor Author

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

@nastra Does this need a separate commit or rebased into the first commit 'Add scalafmt and config for spotless'

@ConeyLiu
Copy link
Contributor Author

could you please raise awareness about this on the DEV mailing list so that people have a chance to review this?

Done it.

@nastra
Copy link
Contributor

nastra commented Jun 24, 2025

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

@nastra Does this need a separate commit or rebased into the first commit 'Add scalafmt and config for spotless'

I think adding this into the first commit should be fine


version = 3.9.7

align = none
Copy link
Member

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)
Copy link
Member

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

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 is because all parameters can be placed in a single line without exceeding the maximum line limit; if the limit is exceeded, they will be stored in multiple columns. I checked the Spark code, and it uses a similar approach.
image

import scala.jdk.CollectionConverters._

class IcebergSparkSqlExtensionsParser(delegate: ParserInterface) extends ParserInterface with ExtendedParser {
class IcebergSparkSqlExtensionsParser(delegate: ParserInterface)
Copy link
Member

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?

@jackylee-ch
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apply spotless for scala code

8 participants