Skip to content

Format filter query values with invariant culture - #190

Merged
mukunku merged 1 commit into
mukunku:mainfrom
PerikiyoXD:pr/culture-invariant-filters
Aug 7, 2026
Merged

Format filter query values with invariant culture#190
mukunku merged 1 commit into
mukunku:mainfrom
PerikiyoXD:pr/culture-invariant-filters

Conversation

@PerikiyoXD

Copy link
Copy Markdown
Contributor

GenerateFilterQuery builds a DataView.RowFilter expression, and that syntax is culture invariant:
it always expects . as the decimal separator and a Gregorian calendar.

Both the numeric and DateTime paths were formatting with the current culture instead.

On a locale that uses a comma as the decimal separator, a float rendered as 1,5.
Inside an IN (...) clause the comma also separates values, so the filter silently matched the wrong rows rather than failing outright.

On a locale with a non-Gregorian default calendar, such as th-TH, the DateTime path emitted year 2567 for 2024.
A custom format string does not avoid this: it still resolves the calendar from the current culture.

This is already visible in the existing suite.

FloatScientificNotation_IsWrappedInQuotes fails on any comma-decimal machine, expecting 1.23E+20 and getting 1,23E+20. It passes in CI only because the runner is en-US.

The added test pins the culture explicitly so the regression is caught wherever the suite runs.

Verified locally: dotnet test goes from 1 failure to 0 on an es-ES machine.

GenerateFilterQuery builds a DataView.RowFilter expression, whose syntax
is culture invariant: it always expects '.' as the decimal separator and
a Gregorian calendar. Both the numeric and DateTime paths were formatting
with the current culture instead.

On a comma-decimal locale a float rendered as "1,5". Inside an IN (...)
clause the comma also separates values, so the filter silently matched
the wrong rows rather than failing outright. On a locale with a
non-Gregorian default calendar, such as th-TH, the DateTime path emitted
year 2567 for 2024. Note that a custom format string does not avoid this:
it still resolves the calendar from the current culture.

This was already covered by FloatScientificNotation_IsWrappedInQuotes,
which failed on any comma-decimal machine but passed in CI under en-US.
The new test pins the culture explicitly so the regression is caught
regardless of where the suite runs.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes culture-dependent formatting in ParquetGridView.GenerateFilterQuery, ensuring DataView.RowFilter expressions are generated using invariant syntax (e.g., . decimal separator and Gregorian calendar) regardless of the user’s locale.

Changes:

  • Format DateTime filter literals using CultureInfo.InvariantCulture to avoid non-Gregorian calendar years (e.g., th-TH).
  • Format numeric filter values using invariant culture to prevent comma-decimal locales from corrupting IN (...) clauses.
  • Add a regression test that explicitly pins the current culture to multiple problematic locales to ensure consistent behavior across environments.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/ParquetViewer/Controls/ParquetGridView.cs Updates numeric and DateTime filter value formatting to use invariant culture for RowFilter correctness.
src/ParquetViewer.Tests/HelperTests.cs Adds a culture-pinned regression test covering numeric literals, scientific notation, IN (...) lists, and DateTime literals.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mukunku

mukunku commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Another great fix, thanks so much 🙏🏾

@mukunku
mukunku merged commit ed781aa into mukunku:main Aug 7, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants