Skip to content

[SPARK-52704][SQL] Simplify interoperations between SQLConf and file-format options in TextBasedFileFormats #51398

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

Closed
wants to merge 1 commit into from

Conversation

yaooqinn
Copy link
Member

@yaooqinn yaooqinn commented Jul 8, 2025

What changes were proposed in this pull request?

Simplify interoperations between SQLConf and file-format options in TextBasedFileFormats

Why are the changes needed?

  • Reduce code duplication
  • Restore type annotation for IDE

Does this PR introduce any user-facing change?

No

How was this patch tested?

existing tests

Was this patch authored or co-authored using generative AI tooling?

no

@github-actions github-actions bot added the SQL label Jul 8, 2025
Copy link
Contributor

@LuciferYang LuciferYang left a comment

Choose a reason for hiding this comment

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

+1, LGTM
This refactoring appears to be safe. thank you @yaooqinn

@yaooqinn yaooqinn closed this in cdd7f22 Jul 8, 2025
@yaooqinn
Copy link
Member Author

yaooqinn commented Jul 8, 2025

The Docker IT failure is a known issue,

Merged to master, thank you @LuciferYang

@yaooqinn yaooqinn deleted the SPARK-52704 branch July 8, 2025 08:44
Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

Sorry but I'm not sure why trait FileFormat should have these utility classes directly? IMO, these should be designed as a new trait and TextBasedFileFormats can use them by additional with clause. WDYT, @yaooqinn and @LuciferYang ?

  protected def sessionState(sparkSession: SparkSession): SessionState = {
    sparkSession.sessionState
  }

  protected def sqlConf(sparkSession: SparkSession): SQLConf = {
    sessionState(sparkSession).conf
  }

  protected def hadoopConf(
      sparkSession: SparkSession,
      options: Map[String, String]): Configuration = {
    sessionState(sparkSession).newHadoopConfWithOptions(options)
  }


protected def sessionState(sparkSession: SparkSession): SessionState = {
sparkSession.sessionState
}
Copy link
Member

Choose a reason for hiding this comment

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

According to the method body, this method is a kind of utility method which can be a static method also.


protected def sqlConf(sparkSession: SparkSession): SQLConf = {
sessionState(sparkSession).conf
}
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 the same. Both sqlConf and sessionState can be a utility method which can be a static method also.

sparkSession: SparkSession,
options: Map[String, String]): Configuration = {
sessionState(sparkSession).newHadoopConfWithOptions(options)
}
Copy link
Member

@dongjoon-hyun dongjoon-hyun Jul 8, 2025

Choose a reason for hiding this comment

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

ditto. This method has no relation to any underlying objects or trait FileFormat directly. We had better put this outside independently with the above sessionState and sqlConf methods

@dongjoon-hyun
Copy link
Member

cc @peter-toth

@yaooqinn
Copy link
Member Author

yaooqinn commented Jul 9, 2025

Thank you @dongjoon-hyun for the advices, I will make a followup

@dongjoon-hyun
Copy link
Member

Thank you, @yaooqinn

dongjoon-hyun pushed a commit that referenced this pull request Jul 9, 2025
…FileFormat to SessionStateHelper

### What changes were proposed in this pull request?

Move session state utilities from trait FileFormat to SessionStateHelper

### Why are the changes needed?
To addresses comments from #51398 (review)

### Does this PR introduce _any_ user-facing change?
NO

### How was this patch tested?
existing tests

### Was this patch authored or co-authored using generative AI tooling?
no

Closes #51411 from yaooqinn/SPARK-52704-F.

Authored-by: Kent Yao <yao@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
@dongjoon-hyun
Copy link
Member

cc @peter-toth

asl3 pushed a commit to asl3/spark that referenced this pull request Jul 14, 2025
…format options in TextBasedFileFormats

### What changes were proposed in this pull request?

Simplify interoperations between SQLConf and file-format options in TextBasedFileFormats

### Why are the changes needed?

- Reduce code duplication
- Restore type annotation for IDE

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
existing tests

### Was this patch authored or co-authored using generative AI tooling?
no

Closes apache#51398 from yaooqinn/SPARK-52704.

Authored-by: Kent Yao <yao@apache.org>
Signed-off-by: Kent Yao <yao@apache.org>
asl3 pushed a commit to asl3/spark that referenced this pull request Jul 14, 2025
…FileFormat to SessionStateHelper

### What changes were proposed in this pull request?

Move session state utilities from trait FileFormat to SessionStateHelper

### Why are the changes needed?
To addresses comments from apache#51398 (review)

### Does this PR introduce _any_ user-facing change?
NO

### How was this patch tested?
existing tests

### Was this patch authored or co-authored using generative AI tooling?
no

Closes apache#51411 from yaooqinn/SPARK-52704-F.

Authored-by: Kent Yao <yao@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
ksbeyer pushed a commit to ksbeyer/spark that referenced this pull request Jul 14, 2025
…format options in TextBasedFileFormats

### What changes were proposed in this pull request?

Simplify interoperations between SQLConf and file-format options in TextBasedFileFormats

### Why are the changes needed?

- Reduce code duplication
- Restore type annotation for IDE

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
existing tests

### Was this patch authored or co-authored using generative AI tooling?
no

Closes apache#51398 from yaooqinn/SPARK-52704.

Authored-by: Kent Yao <yao@apache.org>
Signed-off-by: Kent Yao <yao@apache.org>
ksbeyer pushed a commit to ksbeyer/spark that referenced this pull request Jul 14, 2025
…FileFormat to SessionStateHelper

### What changes were proposed in this pull request?

Move session state utilities from trait FileFormat to SessionStateHelper

### Why are the changes needed?
To addresses comments from apache#51398 (review)

### Does this PR introduce _any_ user-facing change?
NO

### How was this patch tested?
existing tests

### Was this patch authored or co-authored using generative AI tooling?
no

Closes apache#51411 from yaooqinn/SPARK-52704-F.

Authored-by: Kent Yao <yao@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants