Skip to content

Commit ddb0201

Browse files
authored
Merge pull request #1534 from keboola/jirka/inc24802-test
2 parents 00db1dd + 057977a commit ddb0201

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

tests/Backend/Workspaces/SnowflakeDynamicBackendsTest.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public function setUp(): void
5757
foreach ($this->listTestWorkspaces($this->client2) as $workspace) {
5858
$this->workspaces2->deleteWorkspace($workspace['id'], [], true);
5959
}
60+
61+
$this->initEmptyTestBucketsForParallelTests();
6062
}
6163

6264
/**
@@ -341,4 +343,51 @@ private function assertDataInWorkspace(SnowflakeWorkspaceBackend $backend)
341343
'id',
342344
);
343345
}
346+
347+
public function testImportToStorageFromWorkspaceWithDynamicBackend(): void
348+
{
349+
// trying to add columns on the fly on SNFLK "typed" table
350+
$tableDefinition = [
351+
'name' => 'MOJE_SUPERKULATOUCKA_TABULECKA',
352+
'primaryKeysNames' => ['mujesuperhranateid'],
353+
'columns' => [
354+
[
355+
'name' => 'mujesuperhranateid',
356+
'basetype' => 'INTEGER',
357+
],
358+
[
359+
'name' => 'name',
360+
'basetype' => 'STRING',
361+
],
362+
],
363+
];
364+
365+
$typedTableId = $this->_client->createTableDefinition($this->getTestBucketId(), $tableDefinition);
366+
367+
$workspaces = $this->workspaces;
368+
369+
// 1. Create workspace with dynamic backend size 'testsize'
370+
$workspace = $workspaces->createWorkspace([
371+
'backend' => StorageApiTestCase::BACKEND_SNOWFLAKE,
372+
'backendSize' => 'testsize',
373+
]);
374+
$this->assertSame('testsize', $workspace['backendSize']);
375+
376+
// 2. Prepare table in workspace
377+
$backend = WorkspaceBackendFactory::createWorkspaceBackend($workspace);
378+
$tableName = 'MOJE_SUPERKULATOUCKA_TABULECKA';
379+
$backend->createTable($tableName, ['mujesuperhranateid' => 'INTEGER', 'name' => 'VARCHAR']);
380+
$this->assertCount(1, $backend->getTables());
381+
$backend->executeQuery("INSERT INTO MOJE_SUPERKULATOUCKA_TABULECKA VALUES (1, 'martin');");
382+
383+
// 3. Import table from workspace to storage
384+
$this->_client->writeTableAsyncDirect($typedTableId, [
385+
'dataWorkspaceId' => $workspace['id'],
386+
'dataTableName' => 'MOJE_SUPERKULATOUCKA_TABULECKA',
387+
'incremental' => true,
388+
]);
389+
// There is no way to assert the warehouse used for import.
390+
// You can only check it in the UI in Snowflake's QueryHistory or in SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY.
391+
// You should see the warehouse with suffix "_TESTSIZE" in the name.
392+
}
344393
}

0 commit comments

Comments
 (0)