-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
[SPARK-36680][SQL][FOLLOWUP] Files with options should be put into resolveDataSource function #47370
Conversation
…solveDataSource function
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.
Looks good to me, minor nit. Thanks for supporting Files DS
sparkSession, | ||
paths = Seq(ident.last), | ||
className = ident.head, | ||
options = unresolved.options.asCaseSensitiveMap.asScala.toMap) |
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 think we can remove .asCaseSensitiveMap
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.
Thank you , I have removed this asCaseSensitiveMap
.
cc @huaxingao @cloud-fan could you review this PR? This is my first PR in the Spark community. Thank you :) |
@@ -19,6 +19,8 @@ package org.apache.spark.sql.execution.datasources | |||
|
|||
import java.util.Locale | |||
|
|||
import scala.jdk.CollectionConverters.MapHasAsScala |
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 think it's more common to just import scala.jdk.CollectionConverters._
|
||
test("SPARK-36680: Files hint options should be put into resolveDataSource function") { | ||
val df1 = spark.range(100).toDF() | ||
withTempPath(f => { |
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:
withTempPath { f =>
}
""".stripMargin | ||
) | ||
checkAnswer(df2, df1) | ||
df2.queryExecution.analyzed foreach { |
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.
to make the test more explicit, I suggest to do
val relations = df2.queryExecution.analyzed.collect {
case LogicalRelation(fs: HadoopFsRelation, _, _, _) => fs
}
assert(relations.length == 1)
assert(relations.head.options == ...)
@cloud-fan Thank you very much, I modified the code according to your suggestion, can you take a look at it again? |
thanks, merging to master! |
…solveDataSource function ### What changes were proposed in this pull request? When reading csv, json and other files, pass the options parameter to the rules.resolveDataSource method to make the options parameter effective. This is a bug fix for [apache#46707](apache#46707) szehon-ho ### Why are the changes needed? For the following SQL, the options parameter passed in does not take effect. This is because the rules.resolveDataSource method does not pass the options parameter during the datasource construction process ``` SELECT * FROM csv.`/test/data.csv` WITH (`header` = true, 'delimiter' = '|') ``` ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Unit test in SQLQuerySuite ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47370 from logze/hint-options. Authored-by: lizongze <lizongze@xiaomi.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
…solveDataSource function ### What changes were proposed in this pull request? When reading csv, json and other files, pass the options parameter to the rules.resolveDataSource method to make the options parameter effective. This is a bug fix for [apache#46707](apache#46707) szehon-ho ### Why are the changes needed? For the following SQL, the options parameter passed in does not take effect. This is because the rules.resolveDataSource method does not pass the options parameter during the datasource construction process ``` SELECT * FROM csv.`/test/data.csv` WITH (`header` = true, 'delimiter' = '|') ``` ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Unit test in SQLQuerySuite ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47370 from logze/hint-options. Authored-by: lizongze <lizongze@xiaomi.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
When reading csv, json and other files, pass the options parameter to the rules.resolveDataSource method to make the options parameter effective.
This is a bug fix for #46707 @szehon-ho
Why are the changes needed?
For the following SQL, the options parameter passed in does not take effect. This is because the rules.resolveDataSource method does not pass the options parameter during the datasource construction process
Does this PR introduce any user-facing change?
No
How was this patch tested?
Unit test in SQLQuerySuite
Was this patch authored or co-authored using generative AI tooling?
No