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

tmp test #1253

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
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
167 changes: 161 additions & 6 deletions tests/Backend/Bigquery/TableDefinitionOperationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TableDefinitionOperationsTest extends ParallelWorkspacesTestCase
public function setUp(): void
{
parent::setUp();
$this->tableId = $this->createTableDefinition();
// $this->tableId = $this->createTableDefinition();
}

private function createTableDefinition(): string
Expand Down Expand Up @@ -239,6 +239,159 @@ public function testDataPreviewExoticTypes(): void
}
}

public function testResponses(): void
{
$bucketId = $this->getTestBucketId(self::STAGE_IN);

$data = [
'name' => 'my_new_table',
'primaryKeysNames' => [],
'columns' => [
[
'name' => 'c1',
'definition' => [
'type' => 'INT64',
'nullable' => false,
],
],
[
'name' => 'c2',
'definition' => [
'type' => 'STRING',
'nullable' => true,
],
],
[
'name' => 'c3',
'definition' => [
'type' => 'STRING',
],
],
],
];

$runId = $this->_client->generateRunId();
$this->_client->setRunId($runId);

$resp = $this->_client->apiPostJson("buckets/{$bucketId}/tables-definition", $data);

unset($resp['created']);
$this->assertSame([
'uri' => 'https://localhost:8700/v2/storage/tables/in.c-API-tests-08afca048ed464de8680414e9c6b9a9cf9b8db31.my_new_table',
'id' => 'in.c-API-tests-08afca048ed464de8680414e9c6b9a9cf9b8db31.my_new_table',
'name' => 'my_new_table',
'displayName' => 'my_new_table',
'transactional' => false,
'primaryKey' => [],
'indexType' => null,
'indexKey' => [],
'distributionType' => null,
'distributionKey' => [],
'syntheticPrimaryKeyEnabled' => false,
'lastImportDate' => null,
'lastChangeDate' => null,
'rowsCount' => null,
'dataSizeBytes' => null,
'isAlias' => false,
'isAliasable' => true,
'isTyped' => true,
'tableType' => 'table',
'columns' => [
0 => 'c1',
1 => 'c2',
2 => 'c3',
],
], $resp);

$tableDetail = $this->_client->getTable($resp['id']);
unset(
$tableDetail['created'],
$tableDetail['columnMetadata'],
$tableDetail['attributes'],
$tableDetail['metadata'],
$tableDetail['bucket']['created'],
$tableDetail['bucket']['lastChangeDate'],
);
$this->assertSame([
'uri' => 'https://localhost:8700/v2/storage/tables/in.c-API-tests-08afca048ed464de8680414e9c6b9a9cf9b8db31.my_new_table',
'id' => 'in.c-API-tests-08afca048ed464de8680414e9c6b9a9cf9b8db31.my_new_table',
'name' => 'my_new_table',
'displayName' => 'my_new_table',
'transactional' => false,
'primaryKey' => [],
'indexType' => null,
'indexKey' => [],
'distributionType' => null,
'distributionKey' => [],
'syntheticPrimaryKeyEnabled' => false,
'lastImportDate' => null,
'lastChangeDate' => null,
'rowsCount' => null,
'dataSizeBytes' => null,
'isAlias' => false,
'isAliasable' => true,
'isTyped' => true,
'tableType' => 'table',
'columns' => [
0 => 'c1',
1 => 'c2',
2 => 'c3',
],
'bucket' => [
'uri' => 'https://localhost:8700/v2/storage/buckets/in.c-API-tests-08afca048ed464de8680414e9c6b9a9cf9b8db31',
'id' => 'in.c-API-tests-08afca048ed464de8680414e9c6b9a9cf9b8db31',
'name' => 'c-API-tests-08afca048ed464de8680414e9c6b9a9cf9b8db31',
'displayName' => 'API-tests-08afca048ed464de8680414e9c6b9a9cf9b8db31',
'idBranch' => 5112,
'stage' => 'in',
'description' => 'Keboola\Test\Backend\Bigquery\TableDefinitionOperationsTest\testResponses',
'tables' => 'https://localhost:8700/v2/storage/buckets/in.c-API-tests-08afca048ed464de8680414e9c6b9a9cf9b8db31',
'isReadOnly' => false,
'dataSizeBytes' => 0,
'rowsCount' => 0,
'isMaintenance' => false,
'backend' => 'bigquery',
'sharing' => null,
'hasExternalSchema' => false,
'databaseName' => '',
'metadata' => [],
],
'definition' => [
'primaryKeysNames' => [],
'columns' => [
0 => [
'name' => 'c1',
'definition' => [
'type' => 'INTEGER',
'nullable' => false,
],
'basetype' => 'INTEGER',
'canBeFiltered' => true,
],
1 => [
'name' => 'c2',
'definition' => [
'type' => 'STRING',
'nullable' => true,
],
'basetype' => 'STRING',
'canBeFiltered' => true,
],
2 => [
'name' => 'c3',
'definition' => [
'type' => 'STRING',
'nullable' => true,
],
'basetype' => 'STRING',
'canBeFiltered' => true,
],
],
],
],
$tableDetail);
}

public function testResponseDefinition(): void
{
$tableDetail = $this->_client->getTable($this->tableId);
Expand Down Expand Up @@ -1136,7 +1289,7 @@ public function testLoadingNullValuesToNotNullTypedColumnsFromTable(): void
$client->runQuery(
$client->query(
sprintf(
'INSERT INTO `%s`.`my_new_table_with_nulls` VALUES (1, null);',
'INSERT INTO `%s`.`my_new_table_with_nulls` VALUES (1, NULL);',
$dataset,
),
),
Expand Down Expand Up @@ -1208,9 +1361,9 @@ public function testInsertInvalidTypestampIsUserError(): void
$options['dataFileId'] = $fileId;
$this->expectExceptionMessage(
'Load error: '
.'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. '
.'Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; '
.'line_number: 2 byte_offset_to_start_of_line: 17 col',
. 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. '
. 'Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; '
. 'line_number: 2 byte_offset_to_start_of_line: 17 col',
);
$this->expectException(ClientException::class);
$this->_client->writeTableAsyncDirect($tableId, $options);
Expand Down Expand Up @@ -1647,7 +1800,9 @@ public function testCreateTableDefaults(): void
}

/**
* this testcase is not executed, because it takes too long for very low value. Code is being kept for future reference
* this testcase is not executed, because it takes too long for very low value. Code is being kept for future
* reference
*
* @dataProvider provideDataForIllogicalFilter
*/
public function skipTestIllogicalComparisonInFilter(array $filter): void
Expand Down
158 changes: 157 additions & 1 deletion tests/Backend/Snowflake/TableDefinitionOperationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function setUp(): void
{
parent::setUp();
$this->initEmptyTestBucketsForParallelTests();
$this->tableId = $this->createTableDefinition();
// $this->tableId = $this->createTableDefinition();
}

private function createTableDefinition(): string
Expand Down Expand Up @@ -58,6 +58,162 @@ private function createTableDefinition(): string
return $this->_client->createTableDefinition($bucketId, $data);
}

public function testResponses(): void
{
$bucketId = $this->getTestBucketId(self::STAGE_IN);

$data = [
'name' => 'my_new_table',
'primaryKeysNames' => [],
'columns' => [
[
'name' => 'c1',
'definition' => [
'type' => 'INT',
'nullable' => false,
],
],
[
'name' => 'c2',
'definition' => [
'type' => 'VARCHAR',
'nullable' => true,
],
],
[
'name' => 'c3',
'definition' => [
'type' => 'VARCHAR',
],
],
],
];

$runId = $this->_client->generateRunId();
$this->_client->setRunId($runId);

$resp = $this->_client->apiPostJson("buckets/{$bucketId}/tables-definition", $data);

unset($resp['created']);
$this->assertSame([
'uri' => 'https://localhost:8700/v2/storage/tables/in.c-API-tests-5520ea8161caaa70eef35f32ed31e21867dd0d78.my_new_table',
'id' => 'in.c-API-tests-5520ea8161caaa70eef35f32ed31e21867dd0d78.my_new_table',
'name' => 'my_new_table',
'displayName' => 'my_new_table',
'transactional' => false,
'primaryKey' => [],
'indexType' => null,
'indexKey' => [],
'distributionType' => null,
'distributionKey' => [],
'syntheticPrimaryKeyEnabled' => false,
'lastImportDate' => null,
'lastChangeDate' => null,
'rowsCount' => null,
'dataSizeBytes' => null,
'isAlias' => false,
'isAliasable' => true,
'isTyped' => true,
'tableType' => 'table',
'columns' => [
0 => 'c1',
1 => 'c2',
2 => 'c3',
],
], $resp);

$tableDetail = $this->_client->getTable($resp['id']);
unset(
$tableDetail['created'],
$tableDetail['columnMetadata'],
$tableDetail['attributes'],
$tableDetail['metadata'],
$tableDetail['bucket']['created'],
$tableDetail['bucket']['lastChangeDate'],
);
$this->assertSame([
'uri' => 'https://localhost:8700/v2/storage/tables/in.c-API-tests-5520ea8161caaa70eef35f32ed31e21867dd0d78.my_new_table',
'id' => 'in.c-API-tests-5520ea8161caaa70eef35f32ed31e21867dd0d78.my_new_table',
'name' => 'my_new_table',
'displayName' => 'my_new_table',
'transactional' => false,
'primaryKey' => [],
'indexType' => null,
'indexKey' => [],
'distributionType' => null,
'distributionKey' => [],
'syntheticPrimaryKeyEnabled' => false,
'lastImportDate' => null,
'lastChangeDate' => null,
'rowsCount' => null,
'dataSizeBytes' => null,
'isAlias' => false,
'isAliasable' => true,
'isTyped' => true,
'tableType' => 'table',
'columns' => [
0 => 'c1',
1 => 'c2',
2 => 'c3',
],
'bucket' => [
'uri' => 'https://localhost:8700/v2/storage/buckets/in.c-API-tests-5520ea8161caaa70eef35f32ed31e21867dd0d78',
'id' => 'in.c-API-tests-5520ea8161caaa70eef35f32ed31e21867dd0d78',
'name' => 'c-API-tests-5520ea8161caaa70eef35f32ed31e21867dd0d78',
'displayName' => 'API-tests-5520ea8161caaa70eef35f32ed31e21867dd0d78',
'idBranch' => 6069,
'stage' => 'in',
'description' => 'Keboola\Test\Backend\Snowflake\TableDefinitionOperationsTest\testResponses',
'tables' => 'https://localhost:8700/v2/storage/buckets/in.c-API-tests-5520ea8161caaa70eef35f32ed31e21867dd0d78',
'isReadOnly' => false,
'dataSizeBytes' => 0,
'rowsCount' => 0,
'isMaintenance' => false,
'backend' => 'snowflake',
'sharing' => null,
'hasExternalSchema' => false,
'databaseName' => '',
'metadata' => [],
],
'definition' => [
'primaryKeysNames' => [],
'columns' => [
0 => [
'name' => 'c1',
'definition' => [
'type' => 'NUMBER',
'nullable' => false,
'length' => '38,0',
],
'basetype' => 'NUMERIC',
'canBeFiltered' => true,
],
1 => [
'name' => 'c2',
'definition' => [
'type' => 'VARCHAR',
'nullable' => true,
'length' => '16777216',
],
'basetype' => 'STRING',
'canBeFiltered' => true,
],
2 => [
'name' => 'c3',
'definition' => [
'type' => 'VARCHAR',
'nullable' => true,
'length' => '16777216',
],
'basetype' => 'STRING',
'canBeFiltered' => true,
],
],
],
],
$tableDetail);
}

public function testResponseDefinition(): void
{
$tableDetail = $this->_client->getTable($this->tableId);
Expand Down
Loading