From 5867687e1e379b3c2702342b396791770de81f97 Mon Sep 17 00:00:00 2001 From: Norbert Orzechowicz Date: Sun, 9 Jun 2024 15:43:07 -0500 Subject: [PATCH 1/3] Recognize INT32 with deprecated ConvertedType as DateTimeImmutable object --- .../Data/Converter/BytesStringConverter.php | 2 +- .../Data/Converter/Int32DateConverter.php | 6 +++++- .../Data/Converter/Int32DateConverterTest.php | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/lib/parquet/src/Flow/Parquet/Data/Converter/BytesStringConverter.php b/src/lib/parquet/src/Flow/Parquet/Data/Converter/BytesStringConverter.php index 28bfb34f2..c46678c3f 100644 --- a/src/lib/parquet/src/Flow/Parquet/Data/Converter/BytesStringConverter.php +++ b/src/lib/parquet/src/Flow/Parquet/Data/Converter/BytesStringConverter.php @@ -6,7 +6,7 @@ use Flow\Parquet\BinaryReader\Bytes; use Flow\Parquet\Data\Converter; -use Flow\Parquet\ParquetFile\Schema\{FlatColumn, PhysicalType}; +use Flow\Parquet\ParquetFile\Schema\{ConvertedType, FlatColumn, PhysicalType}; use Flow\Parquet\{Option, Options}; final class BytesStringConverter implements Converter diff --git a/src/lib/parquet/src/Flow/Parquet/Data/Converter/Int32DateConverter.php b/src/lib/parquet/src/Flow/Parquet/Data/Converter/Int32DateConverter.php index 6a1a4b8c3..a94eccfe6 100644 --- a/src/lib/parquet/src/Flow/Parquet/Data/Converter/Int32DateConverter.php +++ b/src/lib/parquet/src/Flow/Parquet/Data/Converter/Int32DateConverter.php @@ -6,7 +6,7 @@ use Flow\Parquet\Data\Converter; use Flow\Parquet\Options; -use Flow\Parquet\ParquetFile\Schema\{FlatColumn, LogicalType, PhysicalType}; +use Flow\Parquet\ParquetFile\Schema\{ConvertedType, FlatColumn, LogicalType, PhysicalType}; final class Int32DateConverter implements Converter { @@ -21,6 +21,10 @@ public function isFor(FlatColumn $column, Options $options) : bool return true; } + if ($column->type() === PhysicalType::INT32 && $column->convertedType() === ConvertedType::DATE) { + return true; + } + return false; } diff --git a/src/lib/parquet/tests/Flow/Parquet/Tests/Unit/Data/Converter/Int32DateConverterTest.php b/src/lib/parquet/tests/Flow/Parquet/Tests/Unit/Data/Converter/Int32DateConverterTest.php index a54e78942..66dbfcbc6 100644 --- a/src/lib/parquet/tests/Flow/Parquet/Tests/Unit/Data/Converter/Int32DateConverterTest.php +++ b/src/lib/parquet/tests/Flow/Parquet/Tests/Unit/Data/Converter/Int32DateConverterTest.php @@ -5,6 +5,8 @@ namespace Flow\Parquet\Tests\Unit\Data\Converter; use Flow\Parquet\Data\Converter\Int32DateConverter; +use Flow\Parquet\Options; +use Flow\Parquet\ParquetFile\Schema\{ConvertedType, FlatColumn, PhysicalType}; use PHPUnit\Framework\TestCase; final class Int32DateConverterTest extends TestCase @@ -20,4 +22,21 @@ public function test_converting_dates() : void $converter->fromParquetType($converter->toParquetType($date)) ); } + + public function test_converting_int32_with_deprecated_converted_type() : void + { + $converter = new Int32DateConverter(); + + self::assertTrue( + $converter->isFor( + new FlatColumn( + 'date', + PhysicalType::INT32, + ConvertedType::DATE, + null, + ), + Options::default() + ) + ); + } } From 0ca4629372b80452a30c1fcb2791729455ee8c8f Mon Sep 17 00:00:00 2001 From: Norbert Orzechowicz Date: Sun, 9 Jun 2024 15:45:05 -0500 Subject: [PATCH 2/3] CS Fixes --- .../src/Flow/Parquet/Data/Converter/BytesStringConverter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/parquet/src/Flow/Parquet/Data/Converter/BytesStringConverter.php b/src/lib/parquet/src/Flow/Parquet/Data/Converter/BytesStringConverter.php index c46678c3f..28bfb34f2 100644 --- a/src/lib/parquet/src/Flow/Parquet/Data/Converter/BytesStringConverter.php +++ b/src/lib/parquet/src/Flow/Parquet/Data/Converter/BytesStringConverter.php @@ -6,7 +6,7 @@ use Flow\Parquet\BinaryReader\Bytes; use Flow\Parquet\Data\Converter; -use Flow\Parquet\ParquetFile\Schema\{ConvertedType, FlatColumn, PhysicalType}; +use Flow\Parquet\ParquetFile\Schema\{FlatColumn, PhysicalType}; use Flow\Parquet\{Option, Options}; final class BytesStringConverter implements Converter From b37ed79bc2321a38526236812d0e5916e93c6935 Mon Sep 17 00:00:00 2001 From: Norbert Orzechowicz Date: Sun, 9 Jun 2024 15:47:54 -0500 Subject: [PATCH 3/3] Removed redundant static analysis error supressions --- src/core/etl/src/Flow/ETL/Filesystem/TmpfileBuffer.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/core/etl/src/Flow/ETL/Filesystem/TmpfileBuffer.php b/src/core/etl/src/Flow/ETL/Filesystem/TmpfileBuffer.php index bdbbbd845..db944eeee 100644 --- a/src/core/etl/src/Flow/ETL/Filesystem/TmpfileBuffer.php +++ b/src/core/etl/src/Flow/ETL/Filesystem/TmpfileBuffer.php @@ -32,11 +32,9 @@ public function seek(int $offset, int $whence = SEEK_SET) : void public function stream() { if ($this->stream === null) { - /** @phpstan-ignore-next-line */ $this->stream = \tmpfile(); } - /** @phpstan-ignore-next-line */ return $this->stream; }