Fixed merging float definitions with different precisions#1577
Merged
norberttech merged 7 commits into1.xfrom Apr 6, 2025
Merged
Fixed merging float definitions with different precisions#1577norberttech merged 7 commits into1.xfrom
norberttech merged 7 commits into1.xfrom
Conversation
Closed
Contributor
Flow PHP - BenchmarksResults of the benchmarks from this PR are compared with the results from 1.x branch. Extractors+-----------------------+-------------------+------+-----+-----------------+------------------+-----------------+
| benchmark | subject | revs | its | mem_peak | mode | rstdev |
+-----------------------+-------------------+------+-----+-----------------+------------------+-----------------+
| CSVExtractorBench | bench_extract_10k | 1 | 3 | 4.883mb +1.48% | 611.149ms -5.71% | ±0.40% -3.12% |
| JsonExtractorBench | bench_extract_10k | 1 | 3 | 4.957mb +1.46% | 1.140s +0.48% | ±0.53% -47.49% |
| ParquetExtractorBench | bench_extract_10k | 1 | 3 | 86.470mb +0.02% | 917.708ms -0.28% | ±0.27% -71.72% |
| TextExtractorBench | bench_extract_10k | 1 | 3 | 4.606mb +0.15% | 38.654ms -1.06% | ±0.91% +9.37% |
| XmlExtractorBench | bench_extract_10k | 1 | 3 | 4.581mb +0.13% | 605.292ms +0.15% | ±1.07% +167.52% |
+-----------------------+-------------------+------+-----+-----------------+------------------+-----------------+
Transformers+-----------------------------+--------------------------+------+-----+------------------+-----------------+----------------+
| benchmark | subject | revs | its | mem_peak | mode | rstdev |
+-----------------------------+--------------------------+------+-----+------------------+-----------------+----------------+
| RenameEntryTransformerBench | bench_transform_10k_rows | 1 | 3 | 127.405mb +0.00% | 68.963ms -4.94% | ±0.90% +13.50% |
+-----------------------------+--------------------------+------+-----+------------------+-----------------+----------------+
Loaders+--------------------+----------------+------+-----+------------------+------------------+-----------------+
| benchmark | subject | revs | its | mem_peak | mode | rstdev |
+--------------------+----------------+------+-----+------------------+------------------+-----------------+
| CSVLoaderBench | bench_load_10k | 1 | 3 | 64.050mb +0.01% | 101.610ms -4.57% | ±1.05% +153.38% |
| JsonLoaderBench | bench_load_10k | 1 | 3 | 84.432mb +0.20% | 98.049ms -2.96% | ±0.57% -29.14% |
| ParquetLoaderBench | bench_load_10k | 1 | 3 | 161.284mb +0.01% | 20.982s -2.01% | ±0.34% -30.79% |
| TextLoaderBench | bench_load_10k | 1 | 3 | 18.138mb +0.04% | 31.429ms -0.90% | ±1.20% +13.69% |
+--------------------+----------------+------+-----+------------------+------------------+-----------------+
Building Blocks+-------------------+----------------------------+------+-----+------------------+------------------+-----------------+
| benchmark | subject | revs | its | mem_peak | mode | rstdev |
+-------------------+----------------------------+------+-----+------------------+------------------+-----------------+
| TypeDetectorBench | bench_type_detector | 1 | 3 | 43.920mb +0.02% | 374.932ms +2.31% | ±0.34% -2.64% |
| TypeDetectorBench | bench_type_detector | 1 | 3 | 11.730mb +0.06% | 75.612ms +2.15% | ±0.79% +12.10% |
| EntryFactoryBench | bench_entry_factory | 1 | 3 | 106.034mb +0.01% | 540.050ms +0.84% | ±1.57% +178.20% |
| EntryFactoryBench | bench_entry_factory | 1 | 3 | 55.224mb +0.01% | 267.383ms +0.32% | ±1.04% +19.08% |
| EntryFactoryBench | bench_entry_factory | 1 | 3 | 14.746mb +0.05% | 58.779ms +0.35% | ±1.46% +63.98% |
| RowsBench | bench_chunk_10_on_10k | 2 | 3 | 97.067mb +0.01% | 3.799ms -7.45% | ±2.22% -8.65% |
| RowsBench | bench_diff_left_1k_on_10k | 2 | 3 | 114.423mb +0.01% | 187.674ms +0.93% | ±0.31% -72.57% |
| RowsBench | bench_diff_right_1k_on_10k | 2 | 3 | 97.143mb +0.01% | 19.064ms +0.41% | ±0.54% -31.93% |
| RowsBench | bench_drop_1k_on_10k | 2 | 3 | 97.942mb +0.01% | 1.796ms -8.55% | ±1.59% -50.84% |
| RowsBench | bench_drop_right_1k_on_10k | 2 | 3 | 97.942mb +0.01% | 1.922ms -23.26% | ±1.57% -50.82% |
| RowsBench | bench_entries_on_10k | 2 | 3 | 96.103mb +0.01% | 5.572ms -4.79% | ±0.90% -59.17% |
| RowsBench | bench_filter_on_10k | 2 | 3 | 96.632mb +0.01% | 16.398ms -8.92% | ±0.26% -92.13% |
| RowsBench | bench_find_on_10k | 2 | 3 | 96.632mb +0.01% | 16.680ms -4.71% | ±1.50% +36.20% |
| RowsBench | bench_find_one_on_10k | 10 | 3 | 95.323mb +0.01% | 1.806μs -9.70% | ±2.57% +0.00% |
| RowsBench | bench_first_on_10k | 10 | 3 | 95.323mb +0.01% | 0.500μs 0.00% | ±0.00% 0.00% |
| RowsBench | bench_flat_map_on_1k | 2 | 3 | 104.541mb +0.01% | 16.530ms -2.87% | ±3.28% +137.14% |
| RowsBench | bench_map_on_10k | 2 | 3 | 134.608mb +0.00% | 75.053ms -5.16% | ±1.73% +43.85% |
| RowsBench | bench_merge_1k_on_10k | 2 | 3 | 97.151mb +0.01% | 1.964ms -6.58% | ±0.94% -73.03% |
| RowsBench | bench_partition_by_on_10k | 2 | 3 | 100.522mb +0.01% | 63.558ms -3.71% | ±0.98% +194.10% |
| RowsBench | bench_remove_on_10k | 2 | 3 | 98.204mb +0.01% | 4.202ms -6.95% | ±2.88% +28.38% |
| RowsBench | bench_sort_asc_on_1k | 2 | 3 | 95.685mb +0.01% | 42.446ms +0.23% | ±1.09% -43.15% |
| RowsBench | bench_sort_by_on_1k | 2 | 3 | 95.685mb +0.01% | 41.680ms -5.58% | ±1.05% -29.42% |
| RowsBench | bench_sort_desc_on_1k | 2 | 3 | 95.685mb +0.01% | 42.788ms -3.29% | ±1.71% -13.43% |
| RowsBench | bench_sort_entries_on_1k | 2 | 3 | 97.763mb +0.01% | 8.236ms -0.02% | ±0.88% -21.61% |
| RowsBench | bench_sort_on_1k | 2 | 3 | 95.513mb +0.01% | 29.987ms -1.27% | ±0.40% -82.44% |
| RowsBench | bench_take_1k_on_10k | 10 | 3 | 95.323mb +0.01% | 14.833μs -23.87% | ±2.75% -2.86% |
| RowsBench | bench_take_right_1k_on_10k | 10 | 3 | 95.323mb +0.01% | 15.983μs -29.48% | ±1.34% -35.17% |
| RowsBench | bench_unique_on_1k | 2 | 3 | 114.424mb +0.01% | 188.778ms +0.08% | ±0.48% -46.38% |
+-------------------+----------------------------+------+-----+------------------+------------------+-----------------+
|
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## 1.x #1577 +/- ##
==========================================
+ Coverage 83.13% 83.26% +0.13%
==========================================
Files 695 702 +7
Lines 18898 19012 +114
==========================================
+ Hits 15710 15831 +121
+ Misses 3188 3181 -7
🚀 New features to boost your workflow:
|
bendavies
reviewed
Apr 6, 2025
| $scale = 6; | ||
| } | ||
|
|
||
| var_dump(\json_encode(['scale' => $scale, 'left_scale' => $leftScale, 'right_scale' => $rightScale, 'left_value' => $leftValue, 'right_value' => $rightValue])); |
Contributor
There was a problem hiding this comment.
(can be automated with https://github.com/spaze/phpstan-disallowed-calls)
Member
Author
There was a problem hiding this comment.
haha it happens to me way too often! Going to add that extension now 🤣
Thats why I release on a schedule, to give myself time to fix those kind of mistakes 🙈
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.
Change Log
Added
Fixed
Changed
Removed
Deprecated
Security
Description
In general all ScalarFunctions can return any value
mixed. This means that the result of scalar function needs to go throughEntryFactoryin order to create an entry.Scalar functions can take their values from:
This means that functions like plus/minus/divide/multiply/mod will always return some float|integer and they wont keep the precision/scale of the input float (if the input was an entry).
In order to fix that, scalar functions can now also return
ScalarResult(mixed $value, Type $type)which is pretty much just a wrapper around the value.This approach is way more flexible that TypedScalarFunction since some return types are dynamic and depends on input arguments, for example
ref('id')->cast(type_int()).The return type of cast depends on the argument.
So now when ScalarResult is returned function can pass over more data, like for example type taken from the input.
But since not all values must come from a entry, all math functions received another argument
ScalarFunction|int $scale = 0which can be used to specify how precise that operation needs to be. Under the hood, scale is passed to the instance ofCalculator.