API, AWS, BigQuery, Core, Flink, Hive, Nessie, ORC, Parquet, Spark: Use Locale.ROOT instead of Locale.ENGLISH for case conversion - #17442
Conversation
The SortDirection serializer used Locale.ENGLISH while the null-order parser in the same class uses Locale.ROOT. This aligns on Locale.ROOT for locale-independent canonical output, per project convention. Output is byte-identical for the ASCII enum values.
szehon-ho
left a comment
There was a problem hiding this comment.
Looks good — safe consistency fix.
SortDirection values are ASCII (ASC/DESC), so toLowerCase(Locale.ENGLISH) and toLowerCase(Locale.ROOT) produce identical "asc"/"desc" output. Aligns with the null-order parser in the same class and the project convention to use Locale.ROOT for case conversion. No behavioral or compatibility risk.
There was a problem hiding this comment.
There are a few more Locale.ENGLISH conversions in core (SnapshotRefParser, ContentFileParser, TimerResultParser, TableMetadataParser, IsolationLevel, CatalogUtil,MetricsModes, ExpressionParser, Avro).
Happy to do a follow up for those unless you were planning to.
uros-b
left a comment
There was a problem hiding this comment.
Thank you folks, I'll push some more changes here for a more holistic / complete fix
Replace the remaining Locale.ENGLISH usages with Locale.ROOT across all modules (api, core, aws, bigquery, flink, hive-metastore, nessie, orc, parquet, spark) for consistency with the rest of the codebase. Output is byte-identical: these call sites all pass an explicit locale to toUpperCase/toLowerCase over ASCII enum names and canonical tokens, and ROOT and ENGLISH produce the same result for ASCII. No behavior change.
szehon-ho
left a comment
There was a problem hiding this comment.
Looks good. This PR only replaces the locale argument for toLowerCase/toUpperCase calls. Locale.ROOT and Locale.ENGLISH use the same Unicode case mappings, while Locale.ROOT better expresses that these protocol values, enum names, and serialized tokens are language-neutral. The change is behavior-preserving and aligns the codebase with the established convention.
This aligns the whole codebase on
Locale.ROOTfor locale-independent case conversion, which is the project convention (the checkstyle / Error Prone locale rules recommendLocale.ROOT, and the tree already used it in ~374 places versus a residual ~58 uses ofLocale.ENGLISH).This PR replaces every remaining
Locale.ENGLISHwithLocale.ROOTacross all modules (API, AWS, BigQuery, Core,Flink, Hive, Nessie, ORC, Parquet, Spark).Output is byte-identical: these call sites all pass an explicit locale to
toUpperCase/toLowerCaseover ASCII enum names and canonical tokens, andLocale.ROOTandLocale.ENGLISHproduce the same result for ASCII, so there is no behavior change. TheSortOrderParserchange is kept as the first commit and the remaining occurrences are swept in a follow-up commit; one line inContentFileParseris reflowed by spotless becauseLocale.ROOTis shorter.