Skip to content

Commit

Permalink
[SPARK-45844][SQL][FOLLOWUP] Improve the caseSensitivityOrdering for …
Browse files Browse the repository at this point in the history
…XmlInferSchema

### What changes were proposed in this pull request?
apache#43722 implement case-insensitivity for XML.
But there are a little issue looks weird.

### Why are the changes needed?
Improve the caseSensitivityOrdering for XmlInferSchema

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

### How was this patch tested?
Exists test cases.

### Was this patch authored or co-authored using generative AI tooling?
'No'.

Closes apache#43802 from beliefer/SPARK-45844_followup.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
  • Loading branch information
beliefer authored and HyukjinKwon committed Nov 15, 2023
1 parent 39c012e commit 121b6b8
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,11 @@ private[sql] class XmlInferSchema(options: XmlOptions, caseSensitive: Boolean)
* In case-insensitive mode, we will infer an array named by foo
* (as it's the first one we encounter)
*/
val caseSensitivityOrdering: Ordering[String] = (x: String, y: String) =>
if (caseSensitive) {
x.compareTo(y)
} else {
x.compareToIgnoreCase(y)
}
val caseSensitivityOrdering: Ordering[String] = if (caseSensitive) {
(x: String, y: String) => x.compareTo(y)
} else {
(x: String, y: String) => x.compareToIgnoreCase(y)
}

val nameToDataType =
collection.mutable.TreeMap.empty[String, DataType](caseSensitivityOrdering)
Expand Down

0 comments on commit 121b6b8

Please sign in to comment.