Commit 6861d80
Add PreferFloats static parameter to CsvProvider (#1655)
* 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>1 parent 0cf5625 commit 6861d80
7 files changed
Lines changed: 56 additions & 11 deletions
File tree
- src
- FSharp.Data.Csv.Core
- FSharp.Data.DesignTime/Csv
- FSharp.Data.Html.Core
- FSharp.Data.Runtime.Utilities
- tests
- FSharp.Data.DesignTime.Tests
- FSharp.Data.Tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| |||
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
143 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
144 | 153 | | |
145 | 154 | | |
146 | 155 | | |
| |||
305 | 314 | | |
306 | 315 | | |
307 | 316 | | |
| 317 | + | |
308 | 318 | | |
309 | 319 | | |
310 | 320 | | |
| |||
358 | 368 | | |
359 | 369 | | |
360 | 370 | | |
| 371 | + | |
361 | 372 | | |
362 | 373 | | |
363 | 374 | | |
| |||
456 | 467 | | |
457 | 468 | | |
458 | 469 | | |
| 470 | + | |
459 | 471 | | |
460 | 472 | | |
461 | 473 | | |
| |||
469 | 481 | | |
470 | 482 | | |
471 | 483 | | |
| 484 | + | |
472 | 485 | | |
473 | 486 | | |
474 | 487 | | |
| |||
497 | 510 | | |
498 | 511 | | |
499 | 512 | | |
500 | | - | |
| 513 | + | |
| 514 | + | |
501 | 515 | | |
502 | 516 | | |
503 | 517 | | |
| |||
511 | 525 | | |
512 | 526 | | |
513 | 527 | | |
| 528 | + | |
514 | 529 | | |
515 | 530 | | |
516 | 531 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
119 | | - | |
| 120 | + | |
| 121 | + | |
120 | 122 | | |
121 | 123 | | |
122 | 124 | | |
| |||
241 | 243 | | |
242 | 244 | | |
243 | 245 | | |
244 | | - | |
| 246 | + | |
| 247 | + | |
245 | 248 | | |
246 | 249 | | |
247 | 250 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
525 | 525 | | |
526 | 526 | | |
527 | 527 | | |
| 528 | + | |
528 | 529 | | |
529 | 530 | | |
530 | 531 | | |
| |||
573 | 574 | | |
574 | 575 | | |
575 | 576 | | |
576 | | - | |
| 577 | + | |
577 | 578 | | |
578 | 579 | | |
579 | 580 | | |
| |||
622 | 623 | | |
623 | 624 | | |
624 | 625 | | |
625 | | - | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
626 | 631 | | |
627 | 632 | | |
628 | 633 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
414 | | - | |
| 414 | + | |
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
| |||
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
124 | | - | |
| 125 | + | |
| 126 | + | |
125 | 127 | | |
126 | 128 | | |
127 | 129 | | |
| |||
284 | 286 | | |
285 | 287 | | |
286 | 288 | | |
287 | | - | |
| 289 | + | |
| 290 | + | |
288 | 291 | | |
289 | 292 | | |
290 | 293 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
766 | 766 | | |
767 | 767 | | |
768 | 768 | | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
0 commit comments