-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[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
Conversation
…format options in TextBasedFileFormats
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.
+1, LGTM
This refactoring appears to be safe. thank you @yaooqinn
The Docker IT failure is a known issue, Merged to master, thank you @LuciferYang |
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.
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 | ||
} |
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.
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 | ||
} |
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 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) | ||
} |
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.
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
cc @peter-toth |
Thank you @dongjoon-hyun for the advices, I will make a followup |
Thank you, @yaooqinn |
…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>
cc @peter-toth |
…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>
…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>
…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>
…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>
What changes were proposed in this pull request?
Simplify interoperations between SQLConf and file-format options in TextBasedFileFormats
Why are the changes needed?
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