Skip to content

Commit

Permalink
Fixed calculating column chunk statistics for empty array values
Browse files Browse the repository at this point in the history
  • Loading branch information
norberttech committed Jul 15, 2024
1 parent ab5af92 commit 1be9d01
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 108 deletions.
48 changes: 24 additions & 24 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public function add(string|int|float|array|bool|object|null $value) : void
}

if (\is_array($value)) {
$this->valuesCount += \count($value);
$arrayValuesCount = \count($value);
$this->valuesCount += $arrayValuesCount ?: 1;
} else {
$this->valuesCount++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Flow\Parquet\Tests\Integration\ParquetFile\RowGroupBuilder;

use Flow\Parquet\ParquetFile\RowGroupBuilder\ColumnChunkStatistics;
use Flow\Parquet\ParquetFile\Schema\FlatColumn;
use Flow\Parquet\ParquetFile\Schema\{FlatColumn, ListElement, NestedColumn};
use PHPUnit\Framework\TestCase;

final class ColumnChunkStatisticsTest extends TestCase
Expand Down Expand Up @@ -181,6 +181,23 @@ public function test_statistics_for_json() : void
self::assertSame(1, $statistics->nullCount());
}

public function test_statistics_for_list_of_ints() : void
{
/** @var FlatColumn $listElement */
$listElement = NestedColumn::list('list_of_ints', ListElement::int64())->getListElement();

$statistics = new ColumnChunkStatistics($listElement);

$statistics->add([]);
$statistics->add([1]);
$statistics->add([1, 2]);
$statistics->add([1, 2, 3]);

self::assertSame(1, $statistics->min());
self::assertSame(3, $statistics->max());
self::assertSame(7, $statistics->valuesCount());
}

public function test_statistics_for_string() : void
{
$statistics = new ColumnChunkStatistics(FlatColumn::string('string'));
Expand Down
14 changes: 7 additions & 7 deletions tools/blackfire/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 20 additions & 25 deletions tools/box/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions tools/cs-fixer/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1be9d01

Please sign in to comment.