Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognize INT32 with deprecated ConvertedType as DateTimeImmutable object #1094

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/core/etl/src/Flow/ETL/Filesystem/TmpfileBuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
)
);
}
}
Loading