Conversation
Adds a new boolean static parameter `PreferFloats` (default: `false`) to `CsvProvider` that causes the type inference to use `float` instead of `decimal` when a column's values can be parsed as either. This addresses the long-standing feature request in issue #838. The existing behaviour (inferring `decimal`) is preserved by default; set `PreferFloats = true` to opt in to `float` inference. Implementation: - `StructuralInference.fs`: add `preferFloats: bool` parameter to `inferPrimitiveType`; guard the decimal match arm with `when not preferFloats`; add internal helper `getInferedTypeFromStringPreferFloats`. - `CsvInference.fs`: thread `preferFloats` through `inferCellType`, `inferType`, `inferColumnTypes`, and `CsvFile.InferColumnTypes`. - `HtmlInference.fs`: pass `false` for the new parameter (HTML provider is unaffected). - `CsvProvider.fs`: register the new static parameter at index 19. - `TypeProviderInstantiation.fs`: update `CsvProviderArgs` record and args array for the design-time test harness. - `CsvProvider.fs` (tests): add two tests covering the new parameter. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
3 tasks
…provider-1772049113-a80f9f561cd98a2e
dsyme
approved these changes
Feb 25, 2026
github-actions bot
added a commit
that referenced
this pull request
Feb 26, 2026
* Add PreferFloats static parameter to CsvProvider Adds a new boolean static parameter `PreferFloats` (default: `false`) to `CsvProvider` that causes the type inference to use `float` instead of `decimal` when a column's values can be parsed as either. This addresses the long-standing feature request in issue #838. The existing behaviour (inferring `decimal`) is preserved by default; set `PreferFloats = true` to opt in to `float` inference. Implementation: - `StructuralInference.fs`: add `preferFloats: bool` parameter to `inferPrimitiveType`; guard the decimal match arm with `when not preferFloats`; add internal helper `getInferedTypeFromStringPreferFloats`. - `CsvInference.fs`: thread `preferFloats` through `inferCellType`, `inferType`, `inferColumnTypes`, and `CsvFile.InferColumnTypes`. - `HtmlInference.fs`: pass `false` for the new parameter (HTML provider is unaffected). - `CsvProvider.fs`: register the new static parameter at index 19. - `TypeProviderInstantiation.fs`: update `CsvProviderArgs` record and args array for the design-time test harness. - `CsvProvider.fs` (tests): add two tests covering the new parameter. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: trigger CI checks --------- Co-authored-by: Repo Assist <copilot@github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Don Syme <dsyme@users.noreply.github.com>
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.
🤖 This is an automated pull request from Repo Assist.
Implements the feature requested in #838 — a new
PreferFloatsstatic parameter forCsvProviderthat opts in tofloatinference overdecimal.Why
By default,
CsvProviderinfersdecimalfor numeric columns with fractional values (e.g.9.99). Whiledecimaloffers exact arithmetic, it is incompatible with many .NET math APIs (sqrt,sin, etc.) and causes friction when the caller needsfloat. This parameter lets users opt in tofloatglobally for a provider.What changes
StructuralInference.fspreferFloats: booltoinferPrimitiveType; guard decimal arm withwhen not preferFloats; add internalgetInferedTypeFromStringPreferFloatsCsvInference.fspreferFloatsthroughinferCellType,inferType,inferColumnTypes,CsvFile.InferColumnTypesHtmlInference.fsfalse(HTML provider unaffected)CsvProvider.fsPreferFloatsstatic parameter at index 19TypeProviderInstantiation.fsCsvProviderArgstest recordCsvProvider.fs(tests)Usage
The
Schemaparameter continues to override inference for individual columns regardless ofPreferFloats.Trade-offs
decimalprovides exact arithmetic;floatdoes not. Users should setPreferFloats=trueonly when they know they needfloatcompatibility (e.g., for math functions).Test Status
All 486/487 design-time tests pass (1 skipped pre-existing). All 68
CsvProvidertests pass (66 existing + 2 new).Closes #838