Format filter query values with invariant culture - #190
Merged
Conversation
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.
There was a problem hiding this comment.
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
DateTimefilter literals usingCultureInfo.InvariantCultureto 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.
Owner
|
Another great fix, thanks so much 🙏🏾 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GenerateFilterQuerybuilds aDataView.RowFilterexpression, and that syntax is culture invariant:it always expects
.as the decimal separator and a Gregorian calendar.Both the numeric and
DateTimepaths 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, theDateTimepath 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_IsWrappedInQuotesfails on any comma-decimal machine, expecting1.23E+20and getting1,23E+20. It passes in CI only because the runner isen-US.The added test pins the culture explicitly so the regression is caught wherever the suite runs.
Verified locally:
dotnet testgoes from 1 failure to 0 on anes-ESmachine.