Skip to content

Commit

Permalink
Prevent fatal error when no values are set in ColumnChunkStatistics
Browse files Browse the repository at this point in the history
  • Loading branch information
stloyd committed Oct 28, 2023
1 parent 13bb41b commit 6f325c6
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,28 @@ public function add(string|int|float|null|array|bool|object $value) : void

public function avgStringLength() : int
{
if (0 === $this->notNullCount()) {
return 0;
}

return (int) \ceil($this->totalStringLength / $this->notNullCount());
}

public function cardinalityRation() : float
{
if (0 === $this->notNullCount()) {
return 0;
}

return \round($this->distinctCount() / $this->notNullCount(), 2);
}

public function distinctCount() : int
{
if ([] === $this->values) {
return 0;
}

return \count(\array_unique($this->values));
}

Expand Down

0 comments on commit 6f325c6

Please sign in to comment.