Skip to content

Commit

Permalink
Prevent calling same class methods inside of schema files
Browse files Browse the repository at this point in the history
  • Loading branch information
stloyd committed Oct 28, 2023
1 parent 13bb41b commit 5aefdac
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 deletions.
22 changes: 11 additions & 11 deletions src/lib/parquet/src/Flow/Parquet/ParquetFile/Schema/FlatColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ public function ddl() : array
{
return [
/** @phpstan-ignore-next-line */
'type' => $this->type()->name . ($this->logicalType()?->name() !== null ? ' (' . $this->logicalType()?->name() . ')' : ''),
'optional' => $this->repetition()?->value === Repetition::OPTIONAL->value,
'type' => $this->type->name . ($this->logicalType?->name() !== null ? ' (' . $this->logicalType?->name() . ')' : ''),
'optional' => $this->repetition?->value === Repetition::OPTIONAL->value,
];
}

Expand All @@ -161,7 +161,7 @@ public function flatPath() : string
return $this->flatPath;
}

$parent = $this->parent();
$parent = $this->parent;

if ($parent?->schemaRoot) {
$this->flatPath = $this->name;
Expand Down Expand Up @@ -228,11 +228,11 @@ public function isMapElement() : bool
return true;
}

if ($this->parent()?->parent()?->logicalType()?->name() === 'MAP') {
if ($this->parent->parent()?->logicalType()?->name() === 'MAP') {
return true;
}

if ($this->parent()?->parent()?->parent()?->logicalType()?->name() === 'MAP') {
if ($this->parent->parent()?->parent()?->logicalType()?->name() === 'MAP') {
return true;
}

Expand Down Expand Up @@ -297,13 +297,13 @@ public function normalize() : array
{
return [
'type' => 'flat',
'name' => $this->name(),
'name' => $this->name,
'flat_path' => $this->flatPath(),
'physical_type' => $this->type()->name,
'logical_type' => $this->logicalType()?->name(),
'repetition' => $this->repetition()?->name,
'precision' => $this->precision(),
'scale' => $this->scale(),
'physical_type' => $this->type->name,
'logical_type' => $this->logicalType?->name(),
'repetition' => $this->repetition?->name,
'precision' => $this->precision,
'scale' => $this->scale,
'max_definition_level' => $this->maxDefinitionsLevel(),
'max_repetition_level' => $this->maxRepetitionsLevel(),
'children' => null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function decimalData() : ?Decimal

public function is(string $logicalType) : bool
{
return $this->name() === $logicalType;
return $this->name === $logicalType;
}

public function name() : string
Expand All @@ -199,8 +199,8 @@ public function toThrift() : \Flow\Parquet\Thrift\LogicalType
self::BSON => $this->is(self::BSON) ? new \Flow\Parquet\Thrift\BsonType() : null,
self::DATE => $this->is(self::DATE) ? new \Flow\Parquet\Thrift\DateType() : null,
self::DECIMAL => $this->is(self::DECIMAL) ? new \Flow\Parquet\Thrift\DecimalType([
'scale' => $this->decimalData()?->scale(),
'precision' => $this->decimalData()?->precision(),
'scale' => $this->decimal?->scale(),
'precision' => $this->decimal?->precision(),
]) : null,
self::ENUM => $this->is(self::ENUM) ? new \Flow\Parquet\Thrift\EnumType() : null,
self::INTEGER => $this->is(self::INTEGER) ? new \Flow\Parquet\Thrift\IntType() : null,
Expand All @@ -210,11 +210,11 @@ public function toThrift() : \Flow\Parquet\Thrift\LogicalType
self::STRING => $this->is(self::STRING) ? new \Flow\Parquet\Thrift\StringType() : null,
self::TIME => $this->is(self::TIME) ? new \Flow\Parquet\Thrift\TimeType() : null,
self::TIMESTAMP => $this->is(self::TIMESTAMP) ? new \Flow\Parquet\Thrift\TimestampType([
'isAdjustedToUTC' => $this->timestampData()?->isAdjustedToUTC(),
'isAdjustedToUTC' => $this->timestamp?->isAdjustedToUTC(),
'unit' => new TimeUnit([
'MILLIS' => $this->timestampData()?->millis() ? new \Flow\Parquet\Thrift\MilliSeconds() : null,
'MICROS' => $this->timestampData()?->micros() ? new \Flow\Parquet\Thrift\MicroSeconds() : null,
'NANOS' => $this->timestampData()?->nanos() ? new \Flow\Parquet\Thrift\NanoSeconds() : null,
'MILLIS' => $this->timestamp?->millis() ? new \Flow\Parquet\Thrift\MilliSeconds() : null,
'MICROS' => $this->timestamp?->micros() ? new \Flow\Parquet\Thrift\MicroSeconds() : null,
'NANOS' => $this->timestamp?->nanos() ? new \Flow\Parquet\Thrift\NanoSeconds() : null,
]),
]) : null,
self::UNKNOWN => $this->is(self::UNKNOWN) ? new \Flow\Parquet\Thrift\NullType() : null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function ddl() : array
{
$ddlArray = [
'type' => 'group',
'optional' => $this->repetition()?->value === Repetition::OPTIONAL->value,
'optional' => $this->repetition?->value === Repetition::OPTIONAL->value,
'children' => [],
];

Expand All @@ -155,7 +155,7 @@ public function flatPath() : string
return $this->flatPath;
}

$parent = $this->parent();
$parent = $this->parent;

if ($parent?->schemaRoot) {
$this->flatPath = $this->name;
Expand Down Expand Up @@ -187,7 +187,7 @@ public function getListElement() : Column
{
if ($this->isList()) {
/** @phpstan-ignore-next-line */
return $this->children()[0]->children()[0];
return $this->children[0]->children()[0];
}

throw new InvalidArgumentException('Column ' . $this->flatPath() . ' is not a list');
Expand All @@ -200,7 +200,7 @@ public function getMapKeyColumn() : FlatColumn
{
if ($this->isMap()) {
/** @phpstan-ignore-next-line */
return $this->children()[0]->children()[0];
return $this->children[0]->children()[0];
}

throw new InvalidArgumentException('Column ' . $this->flatPath() . ' is not a map');
Expand All @@ -213,15 +213,15 @@ public function getMapValueColumn() : Column
{
if ($this->isMap()) {
/** @phpstan-ignore-next-line */
return $this->children()[0]->children()[1];
return $this->children[0]->children()[1];
}

throw new InvalidArgumentException('Column ' . $this->flatPath() . ' is not a map');
}

public function isList() : bool
{
return $this->logicalType()?->name() === 'LIST';
return $this->logicalType?->name() === 'LIST';
}

public function isListElement() : bool
Expand All @@ -243,7 +243,7 @@ public function isListElement() : bool

public function isMap() : bool
{
return $this->logicalType()?->name() === 'MAP';
return $this->logicalType?->name() === 'MAP';
}

public function isMapElement() : bool
Expand All @@ -252,11 +252,11 @@ public function isMapElement() : bool
return false;
}

if ($this->parent()?->logicalType()?->name() === 'MAP') {
if ($this->parent->logicalType()?->name() === 'MAP') {
return true;
}

if ($this->parent()?->parent()?->logicalType()?->name() === 'MAP') {
if ($this->parent->parent()?->logicalType()?->name() === 'MAP') {
return true;
}

Expand Down Expand Up @@ -299,7 +299,7 @@ public function maxDefinitionsLevel() : int
if ($this->repetition === null) {
$level = 0;
} else {
$level = $this->repetition() === Repetition::REQUIRED ? 0 : 1;
$level = $this->repetition === Repetition::REQUIRED ? 0 : 1;
}

return $this->parent ? $level + $this->parent->maxDefinitionsLevel() : $level;
Expand All @@ -310,7 +310,7 @@ public function maxRepetitionsLevel() : int
if ($this->repetition === null) {
$level = 0;
} else {
$level = $this->repetition() === Repetition::REPEATED ? 1 : 0;
$level = $this->repetition === Repetition::REPEATED ? 1 : 0;
}

return $this->parent ? $level + $this->parent->maxRepetitionsLevel() : $level;
Expand All @@ -325,11 +325,11 @@ public function normalize() : array
{
return [
'type' => 'nested',
'name' => $this->name(),
'name' => $this->name,
'flat_path' => $this->flatPath(),
'physical_type' => $this->type()?->name,
'logical_type' => $this->logicalType()?->name(),
'repetition' => $this->repetition()?->name,
'physical_type' => null,
'logical_type' => $this->logicalType?->name(),
'repetition' => $this->repetition?->name,
'max_definition_level' => $this->maxDefinitionsLevel(),
'max_repetition_level' => $this->maxRepetitionsLevel(),
'children' => $this->normalizeChildren(),
Expand Down Expand Up @@ -393,11 +393,11 @@ public function toThrift() : array
{
$elements = [
new SchemaElement([
'name' => $this->name(),
'name' => $this->name,
'num_children' => \count($this->children),
'converted_type' => null,
'repetition_type' => $this->repetition()?->value,
'logicalType' => $this->logicalType()?->toThrift(),
'repetition_type' => $this->repetition?->value,
'logicalType' => $this->logicalType?->toThrift(),
]),
];

Expand Down

0 comments on commit 5aefdac

Please sign in to comment.