Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function getBackendDefaultValue(string $backend): ?string

public function hasBackendType(string $backend): bool
{
if (!isset($this->mapping[$backend])) {
if (!isset($this->mapping[$backend]['type'])) {
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ public function getRequestData(): array
// $definition['default'] = $dataType->getDefaultValue($this->backend);
// }

if ($definition && !isset($definition['type'])) {
$definition['type'] = $dataType->getTypeName($this->backend);
}
if ($definition) {
if (isset($definition['type'])) {
$data['definition'] = $definition;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,24 @@ public function columnDataProvider(): Generator
'basetype' => 'STRING',
],
];

yield 'backend definition without type' => [
'column' => new MappingFromConfigurationSchemaColumn([
'name' => 'test_table_name',
'data_type' => [
'base' => [
'type' => 'STRING',
],
'snowflake' => [
'length' => '1024',
],
],
]),
'backend' => 'snowflake',
'expectedStructure' => [
'name' => 'test_table_name',
'basetype' => 'STRING',
],
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ public function configProvider(): Generator
],
'birthweight' => [
'type' => Bigquery::TYPE_NUMERIC,
'length' => '38,9',
'nullable' => true,
],
'created' => [
Expand Down
10 changes: 7 additions & 3 deletions libs/output-mapping/tests/Writer/TableDefinitionV2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public function configProvider(): Generator
[
'Id' => [
'type' => Snowflake::TYPE_NUMBER,
'length' => '38,0', // default integer length
'length' => '38,9', // default integer length
'nullable' => false,
],
'Name' => [
Expand Down Expand Up @@ -473,8 +473,12 @@ private static function assertDataTypeDefinition(array $definitionColumn, array
$definitionColumn = current($definitionColumn);

self::assertSame($expectedType['type'], $definitionColumn['definition']['type']);
self::assertSame($expectedType['length'], $definitionColumn['definition']['length']);
self::assertSame($expectedType['nullable'], $definitionColumn['definition']['nullable']);
if (isset($expectedType['length'])) {
self::assertSame($expectedType['length'], $definitionColumn['definition']['length']);
}
if (isset($definitionColumn['nullable'])) {
self::assertSame($expectedType['nullable'], $definitionColumn['definition']['nullable']);
}
}

#[NeedsTestTables]
Expand Down