From f7f1ad987876bda5a708c727b8f5222d8e2719f9 Mon Sep 17 00:00:00 2001 From: Ondra Jodas Date: Mon, 12 Jul 2021 15:20:22 +0200 Subject: [PATCH 1/2] Used different snlfk writer on Azure stacks --- src/DbBackend/SnowflakeBackend.php | 13 ++++- .../DbBeckend/SnowflakeBackendTest.php | 54 +++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 tests/phpunit/DbBeckend/SnowflakeBackendTest.php diff --git a/src/DbBackend/SnowflakeBackend.php b/src/DbBackend/SnowflakeBackend.php index 41b3ec8..bfc493c 100644 --- a/src/DbBackend/SnowflakeBackend.php +++ b/src/DbBackend/SnowflakeBackend.php @@ -10,7 +10,9 @@ class SnowflakeBackend implements DbBackend { - public const COMPONENT_KEBOOLA_WR_DB_SNOWFLAKE = 'keboola.wr-db-snowflake'; + public const COMPONENT_KEBOOLA_WR_DB_SNOWFLAKE_S3 = 'keboola.wr-db-snowflake'; + + public const COMPONENT_KEBOOLA_WR_DB_SNOWFLAKE_ABS = 'keboola.wr-snowflake-blob-storage'; private Config $config; @@ -56,7 +58,14 @@ public function createDbConnectionApiObject(string $connectionName): DBConnectio public function getWriterComponentName(): string { - return self::COMPONENT_KEBOOLA_WR_DB_SNOWFLAKE; + switch ($this->config->getStorageApiUrl()) { + case 'connection.north-europe.azure.keboola.com': + case 'connection.csas.keboola.cloud': + case 'connection.csas-test.keboola.com': + return self::COMPONENT_KEBOOLA_WR_DB_SNOWFLAKE_ABS; + default: + return self::COMPONENT_KEBOOLA_WR_DB_SNOWFLAKE_S3; + } } public function getTestConnectionConfig(): ?array diff --git a/tests/phpunit/DbBeckend/SnowflakeBackendTest.php b/tests/phpunit/DbBeckend/SnowflakeBackendTest.php new file mode 100644 index 0000000..45d0f41 --- /dev/null +++ b/tests/phpunit/DbBeckend/SnowflakeBackendTest.php @@ -0,0 +1,54 @@ +getWriterComponentName()); + } + + public function componentNameDataProvider(): Generator + { + yield 'azure-ne' => [ + 'connection.north-europe.azure.keboola.com', + 'keboola.wr-snowflake-blob-storage' + ]; + + yield 'azure-csas-prod' => [ + 'connection.csas.keboola.cloud', + 'keboola.wr-snowflake-blob-storage' + ]; + + yield 'azure-csas-test' => [ + 'connection.csas-test.keboola.com', + 'keboola.wr-snowflake-blob-storage' + ]; + + yield 'aws-us' => [ + 'connection.keboola.com', + 'keboola.wr-db-snowflake' + ]; + + yield 'aws-eu' => [ + 'connection.eu-central-1.keboola.com', + 'keboola.wr-db-snowflake' + ]; + } +} From f97a61c93b5315bdef213c944f1ccbb0a512f198 Mon Sep 17 00:00:00 2001 From: Ondra Jodas Date: Mon, 12 Jul 2021 16:09:34 +0200 Subject: [PATCH 2/2] fix phpcs --- tests/phpunit/DbBeckend/SnowflakeBackendTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/DbBeckend/SnowflakeBackendTest.php b/tests/phpunit/DbBeckend/SnowflakeBackendTest.php index 45d0f41..e852e7f 100644 --- a/tests/phpunit/DbBeckend/SnowflakeBackendTest.php +++ b/tests/phpunit/DbBeckend/SnowflakeBackendTest.php @@ -28,27 +28,27 @@ public function componentNameDataProvider(): Generator { yield 'azure-ne' => [ 'connection.north-europe.azure.keboola.com', - 'keboola.wr-snowflake-blob-storage' + 'keboola.wr-snowflake-blob-storage', ]; yield 'azure-csas-prod' => [ 'connection.csas.keboola.cloud', - 'keboola.wr-snowflake-blob-storage' + 'keboola.wr-snowflake-blob-storage', ]; yield 'azure-csas-test' => [ 'connection.csas-test.keboola.com', - 'keboola.wr-snowflake-blob-storage' + 'keboola.wr-snowflake-blob-storage', ]; yield 'aws-us' => [ 'connection.keboola.com', - 'keboola.wr-db-snowflake' + 'keboola.wr-db-snowflake', ]; yield 'aws-eu' => [ 'connection.eu-central-1.keboola.com', - 'keboola.wr-db-snowflake' + 'keboola.wr-db-snowflake', ]; } }