Skip to content

Conversation

@f-lapinski
Copy link
Contributor

@f-lapinski f-lapinski commented Feb 7, 2025

Change Log

Added

Fixed

Changed

  • Change StringCamel to StringStyle to using with exisitng Enum StringStyles and get's StringStyle as parameter

Removed

  • Previous StringCamle function, methods and tests

Deprecated

Security


Description

Ref: #1316

The StringStyle function has been added to the codebase with an implemented test to ensure functionality. It has been integrated into the ScalarFunctionChain, enabling its use within the chain of scalar functions. Working with StringStyle enum's.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2025

Flow PHP - Benchmarks

Results 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.798mb +0.01%  | 555.914ms +0.58% | ±0.23% -10.36% |
| JsonExtractorBench    | bench_extract_10k | 1    | 3   | 4.871mb +0.01%  | 1.063s +0.12%    | ±0.43% +7.58%  |
| ParquetExtractorBench | bench_extract_10k | 1    | 3   | 86.312mb +0.00% | 887.466ms -1.89% | ±0.17% -57.12% |
| TextExtractorBench    | bench_extract_10k | 1    | 3   | 4.528mb +0.02%  | 35.403ms +0.64%  | ±1.00% -50.48% |
| XmlExtractorBench     | bench_extract_10k | 1    | 3   | 4.502mb +0.02%  | 603.940ms +0.11% | ±0.21% -78.57% |
+-----------------------+-------------------+------+-----+-----------------+------------------+----------------+
Transformers
+-----------------------------+--------------------------+------+-----+------------------+-----------------+----------------+
| benchmark                   | subject                  | revs | its | mem_peak         | mode            | rstdev         |
+-----------------------------+--------------------------+------+-----+------------------+-----------------+----------------+
| RenameEntryTransformerBench | bench_transform_10k_rows | 1    | 3   | 127.324mb +0.00% | 71.566ms -2.84% | ±0.28% -80.84% |
+-----------------------------+--------------------------+------+-----+------------------+-----------------+----------------+
Loaders
+--------------------+----------------+------+-----+------------------+------------------+----------------+
| benchmark          | subject        | revs | its | mem_peak         | mode             | rstdev         |
+--------------------+----------------+------+-----+------------------+------------------+----------------+
| CSVLoaderBench     | bench_load_10k | 1    | 3   | 63.995mb +0.00%  | 101.767ms -2.59% | ±0.80% -50.20% |
| JsonLoaderBench    | bench_load_10k | 1    | 3   | 84.342mb +0.00%  | 97.764ms -2.43%  | ±0.57% +31.43% |
| ParquetLoaderBench | bench_load_10k | 1    | 3   | 161.183mb +0.00% | 20.592s -0.95%   | ±0.18% -58.22% |
| TextLoaderBench    | bench_load_10k | 1    | 3   | 17.994mb +0.00%  | 31.029ms -3.82%  | ±0.26% +38.13% |
+--------------------+----------------+------+-----+------------------+------------------+----------------+
Building Blocks
+-------------------+----------------------------+------+-----+------------------+------------------+-----------------+
| benchmark         | subject                    | revs | its | mem_peak         | mode             | rstdev          |
+-------------------+----------------------------+------+-----+------------------+------------------+-----------------+
| EntryFactoryBench | bench_entry_factory        | 1    | 3   | 105.967mb +0.00% | 452.792ms -1.86% | ±0.51% +319.87% |
| EntryFactoryBench | bench_entry_factory        | 1    | 3   | 55.157mb +0.00%  | 229.979ms -2.49% | ±1.08% +24.22%  |
| EntryFactoryBench | bench_entry_factory        | 1    | 3   | 14.679mb +0.00%  | 49.957ms -3.23%  | ±0.29% +43.59%  |
| RowsBench         | bench_chunk_10_on_10k      | 2    | 3   | 97.010mb +0.00%  | 3.092ms -26.26%  | ±1.05% -60.69%  |
| RowsBench         | bench_diff_left_1k_on_10k  | 2    | 3   | 114.293mb +0.00% | 186.018ms +0.18% | ±0.34% +15.86%  |
| RowsBench         | bench_diff_right_1k_on_10k | 2    | 3   | 97.013mb +0.00%  | 18.501ms -4.29%  | ±1.19% -46.57%  |
| RowsBench         | bench_drop_1k_on_10k       | 2    | 3   | 97.885mb +0.00%  | 1.447ms -31.23%  | ±3.18% +198.92% |
| RowsBench         | bench_drop_right_1k_on_10k | 2    | 3   | 97.885mb +0.00%  | 1.372ms -35.18%  | ±0.82% -78.74%  |
| RowsBench         | bench_entries_on_10k       | 2    | 3   | 96.046mb +0.00%  | 4.582ms -19.61%  | ±1.99% -16.11%  |
| RowsBench         | bench_filter_on_10k        | 2    | 3   | 96.575mb +0.00%  | 16.981ms -3.37%  | ±0.43% -49.44%  |
| RowsBench         | bench_find_on_10k          | 2    | 3   | 96.575mb +0.00%  | 17.106ms -2.43%  | ±0.91% +70.40%  |
| RowsBench         | bench_find_one_on_10k      | 10   | 3   | 95.266mb +0.00%  | 1.894μs -5.30%   | ±2.53% +0.00%   |
| RowsBench         | bench_first_on_10k         | 10   | 3   | 95.266mb +0.00%  | 0.300μs -25.00%  | ±0.00% -100.00% |
| RowsBench         | bench_flat_map_on_1k       | 2    | 3   | 104.484mb +0.00% | 15.568ms -5.54%  | ±1.90% +4.82%   |
| RowsBench         | bench_map_on_10k           | 2    | 3   | 134.551mb +0.00% | 71.602ms -6.07%  | ±1.11% -2.23%   |
| RowsBench         | bench_merge_1k_on_10k      | 2    | 3   | 97.095mb +0.00%  | 1.250ms -33.22%  | ±1.92% +263.45% |
| RowsBench         | bench_partition_by_on_10k  | 2    | 3   | 100.392mb +0.00% | 66.765ms +2.20%  | ±0.61% +2.86%   |
| RowsBench         | bench_remove_on_10k        | 2    | 3   | 98.147mb +0.00%  | 3.593ms -23.67%  | ±0.55% -77.88%  |
| RowsBench         | bench_sort_asc_on_1k       | 2    | 3   | 95.555mb +0.00%  | 43.307ms +1.02%  | ±0.76% +12.73%  |
| RowsBench         | bench_sort_by_on_1k        | 2    | 3   | 95.555mb +0.00%  | 43.629ms +2.38%  | ±0.77% -73.97%  |
| RowsBench         | bench_sort_desc_on_1k      | 2    | 3   | 95.555mb +0.00%  | 42.978ms +1.34%  | ±0.80% -60.22%  |
| RowsBench         | bench_sort_entries_on_1k   | 2    | 3   | 97.707mb +0.00%  | 8.279ms -8.40%   | ±0.60% -70.64%  |
| RowsBench         | bench_sort_on_1k           | 2    | 3   | 95.456mb +0.00%  | 29.278ms -2.92%  | ±1.27% -23.59%  |
| RowsBench         | bench_take_1k_on_10k       | 10   | 3   | 95.266mb +0.00%  | 13.282μs -8.95%  | ±1.07% +65.15%  |
| RowsBench         | bench_take_right_1k_on_10k | 10   | 3   | 95.266mb +0.00%  | 15.110μs -12.26% | ±2.93% +194.99% |
| RowsBench         | bench_unique_on_1k         | 2    | 3   | 114.294mb +0.00% | 188.737ms -1.90% | ±1.15% +26.88%  |
| TypeDetectorBench | bench_type_detector        | 1    | 3   | 43.802mb +0.00%  | 368.604ms +1.02% | ±1.40% +75.95%  |
| TypeDetectorBench | bench_type_detector        | 1    | 3   | 11.612mb +0.01%  | 72.573ms -0.80%  | ±0.88% -26.32%  |
+-------------------+----------------------------+------+-----+------------------+------------------+-----------------+

@codecov
Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.

Project coverage is 83.03%. Comparing base (99c9179) to head (9f1a60c).
Report is 2 commits behind head on 1.x.

Additional details and impacted files
@@            Coverage Diff             @@
##              1.x    #1453      +/-   ##
==========================================
+ Coverage   83.01%   83.03%   +0.01%     
==========================================
  Files         662      663       +1     
  Lines       17825    17842      +17     
==========================================
+ Hits        14798    14815      +17     
  Misses       3027     3027              
Components Coverage Δ
etl 85.76% <94.44%> (+0.03%) ⬆️
cli 86.73% <ø> (ø)
lib-array-dot 94.53% <ø> (ø)
lib-azure-sdk 62.56% <ø> (ø)
lib-doctrine-dbal-bulk 97.36% <ø> (ø)
lib-filesystem 76.75% <ø> (ø)
lib-parquet 84.33% <ø> (ø)
lib-parquet-viewer 82.02% <ø> (ø)
lib-rdsl 87.09% <ø> (ø)
lib-snappy 90.69% <ø> (ø)
bridge-filesystem-async-aws 90.38% <ø> (ø)
bridge-filesystem-azure 89.92% <ø> (ø)
bridge-monolog-http 96.38% <ø> (ø)
symfony-http-foundation 77.10% <ø> (ø)
adapter-chartjs 86.45% <ø> (ø)
adapter-csv 89.49% <ø> (ø)
adapter-doctrine 88.68% <ø> (ø)
adapter-elasticsearch 97.19% <ø> (ø)
adapter-google-sheet 78.04% <ø> (ø)
adapter-http 59.15% <ø> (ø)
adapter-json 90.81% <ø> (ø)
adapter-logger 53.84% <ø> (ø)
adapter-meilisearch 97.75% <ø> (ø)
adapter-parquet 80.85% <ø> (ø)
adapter-text 84.44% <ø> (ø)
adapter-xml 83.15% <ø> (ø)

@f-lapinski
Copy link
Contributor Author

1) Flow\ETL\Tests\Unit\Function\StringStyleTest::test_string_style_kebab Error: Call to undefined method Symfony\Component\String\UnicodeString::kebab()

Test throwing error about string method kebab(), cause it's avaliable on symfony 7.2+
There is two options i think, move Smyofny-string package to 7.2 or exclude kebab from tests.


final class StringStyle extends ScalarFunctionChain implements TypedScalarFunction
{
public function __construct(private readonly ScalarFunction|string $string, private readonly StringStyles $style)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a ScalarFunction|string|StringStyles so you can use it like this:

ref()->stringStyle('snake')
ref()->stringStyle(StringStyles::SNAKE)
ref()->stringStyle(ref('style'))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done :)

@norberttech
Copy link
Member

1) Flow\ETL\Tests\Unit\Function\StringStyleTest::test_string_style_kebab Error: Call to undefined method Symfony\Component\String\UnicodeString::kebab()

Test throwing error about string method kebab(), cause it's avaliable on symfony 7.2+ There is two options i think, move Smyofny-string package to 7.2 or exclude kebab from tests.

So if you look at u()->kebab() this is what you are going to see:

   public function kebab(): static
    {
        return $this->snake()->replace('_', '-');
    }

So all we need to do is at the level of StringStyles, check if kebab method is available on UnicodeString and if not do $this->snake()->replace('_', '-')

@norberttech norberttech changed the title Add StringCamel ScalarFunction Add StringStyle ScalarFunction Feb 8, 2025
f-lapinski and others added 4 commits February 8, 2025 20:50
…s parameter

Check if kebab() method is avaliable and return it if yes and replace the method if no
…s parameter

Use method kebab or snake->replace depends on symfony version
$string = (new Parameter($this->string))->asString($row);
$style = (new Parameter($this->style))->as($row, type_string(), type_enum(StringStyles::class));

if ($string === null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you also need to check if style is not null here

@norberttech norberttech merged commit 2c6768b into flow-php:1.x Feb 8, 2025
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants