Skip to content

[Repo Assist] Add PreferFloats static parameter to CsvProvider#1655

Merged
dsyme merged 3 commits intomainfrom
repo-assist/fix-issue-838-prefer-floats-csv-provider-1772049113-a80f9f561cd98a2e
Feb 25, 2026
Merged

[Repo Assist] Add PreferFloats static parameter to CsvProvider#1655
dsyme merged 3 commits intomainfrom
repo-assist/fix-issue-838-prefer-floats-csv-provider-1772049113-a80f9f561cd98a2e

Conversation

@github-actions
Copy link
Contributor

🤖 This is an automated pull request from Repo Assist.

Implements the feature requested in #838 — a new PreferFloats static parameter for CsvProvider that opts in to float inference over decimal.

Why

By default, CsvProvider infers decimal for numeric columns with fractional values (e.g. 9.99). While decimal offers exact arithmetic, it is incompatible with many .NET math APIs (sqrt, sin, etc.) and causes friction when the caller needs float. This parameter lets users opt in to float globally for a provider.

What changes

File Change
StructuralInference.fs Add preferFloats: bool to inferPrimitiveType; guard decimal arm with when not preferFloats; add internal getInferedTypeFromStringPreferFloats
CsvInference.fs Thread preferFloats through inferCellType, inferType, inferColumnTypes, CsvFile.InferColumnTypes
HtmlInference.fs Pass false (HTML provider unaffected)
CsvProvider.fs Register PreferFloats static parameter at index 19
TypeProviderInstantiation.fs Update CsvProviderArgs test record
CsvProvider.fs (tests) Add two tests

Usage

// Default: columns with 9.99-style values infer as decimal
type PricesDefault = CsvProvider<"prices.csv">
// prices.Price : decimal

// With PreferFloats=true: same columns infer as float
type PricesFloat = CsvProvider<"prices.csv", PreferFloats = true>
// prices.Price : float

The Schema parameter continues to override inference for individual columns regardless of PreferFloats.

Trade-offs

  • decimal provides exact arithmetic; float does not. Users should set PreferFloats=true only when they know they need float compatibility (e.g., for math functions).
  • This is a purely additive, opt-in change. Default behaviour is unchanged.

Test Status

All 486/487 design-time tests pass (1 skipped pre-existing). All 68 CsvProvider tests pass (66 existing + 2 new).

Closes #838

Generated by Repo Assist

To install this workflow, run gh aw add githubnext/agentics/workflows/repo-assist.md@f2c5cf1e4af58e09a93ba0703c6bf084711b265f. View source at https://github.com/githubnext/agentics/tree/f2c5cf1e4af58e09a93ba0703c6bf084711b265f/workflows/repo-assist.md.

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>
@dsyme dsyme marked this pull request as ready for review February 25, 2026 20:22
@dsyme dsyme merged commit ec474ef into main Feb 25, 2026
1 of 2 checks passed
@dsyme dsyme deleted the repo-assist/fix-issue-838-prefer-floats-csv-provider-1772049113-a80f9f561cd98a2e branch February 25, 2026 20:23
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add PreferFloats static param to CsvProvider

1 participant