-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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-51496][SQL] CaseInsensitiveStringMap comparison should ignore case #50275
Conversation
because one of |
@pan3793
ManualSource.TABLE_NAME is upper case. If calling .option(ManualSource.TABLE_NAME, manualTableName) changing the key to lower case, I will get
|
cc @cloud-fan |
shall we be case-preserving and do not lower case the keys when creating |
When creating a CaseInsensitiveStringMap, the keys are changed to lower case in the constructor. This |
@@ -125,7 +125,14 @@ object V2Writes extends Rule[LogicalPlan] with PredicateHelper { | |||
// for DataFrame API cases, same options are carried by both Command and DataSourceV2Relation | |||
// for DataFrameV2 API cases, options are only carried by Command | |||
// for SQL cases, options are only carried by DataSourceV2Relation | |||
assert(commandOptions == dsOptions || commandOptions.isEmpty || dsOptions.isEmpty) |
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 way we turn CaseInsensitiveStringMap
to a scala Map is r.options.asScala.toMap
, I think we should change it to r.options.asCaseSensitiveMap.asScala.toMap
to be case preserving
thanks, merging to master/4.0! |
…case ### What changes were proposed in this pull request? Since both `commandOptions` and `dsOptions` are `CaseInsensitiveStringMap` objects, I think we should convert the keys and values to lowercase before comparing them ### Why are the changes needed? In iceberg/spark4.0 integration, I got a few assertion errors: ``` assertion failed java.lang.AssertionError: assertion failed at scala.Predef$.assert(Predef.scala:264) at org.apache.spark.sql.execution.datasources.v2.V2Writes$.org$apache$spark$sql$execution$datasources$v2$V2Writes$$mergeOptions(V2Writes.scala:128) ``` The assertion error occurs when comparing commandOptions and dsOptions; the cases of the keys don't match. ``` assert(commandOptions == dsOptions) ``` ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? I have verified that the iceberg tests can pass with this fix. ### Was this patch authored or co-authored using generative AI tooling? no Closes #50275 from huaxingao/mergeOptions. Authored-by: huaxingao <huaxin.gao11@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit bfe63a3) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
Thanks @cloud-fan |
What changes were proposed in this pull request?
Since both
commandOptions
anddsOptions
areCaseInsensitiveStringMap
objects, I think we should convert the keys and values to lowercase before comparing themWhy are the changes needed?
In iceberg/spark4.0 integration, I got a few assertion errors:
The assertion error occurs when comparing commandOptions and dsOptions; the cases of the keys don't match.
Does this PR introduce any user-facing change?
No
How was this patch tested?
I have verified that the iceberg tests can pass with this fix.
Was this patch authored or co-authored using generative AI tooling?
no