From e6f81bb1fa925144a1bf8f2980763db1233027e6 Mon Sep 17 00:00:00 2001 From: Christian Allred Date: Tue, 3 Sep 2024 12:15:38 -0600 Subject: [PATCH] fix(snowflake): fixing the snowflake schema fetcher logic (#7440) --- .../product/configuration/data-sources/snowflake.mdx | 6 ++++++ .../cubejs-snowflake-driver/src/SnowflakeDriver.ts | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/pages/product/configuration/data-sources/snowflake.mdx b/docs/pages/product/configuration/data-sources/snowflake.mdx index 1f0032581582f..fff6f0c5b9f0d 100644 --- a/docs/pages/product/configuration/data-sources/snowflake.mdx +++ b/docs/pages/product/configuration/data-sources/snowflake.mdx @@ -12,6 +12,12 @@ redirect_from: - [The region][snowflake-docs-regions] for the [Snowflake][snowflake] warehouse - The username/password for the [Snowflake][snowflake] account +## Snowflake quoted identifiers + +Due to an issue in snowflakes opinion about quoted identifers we set a session value to override +snowflake defaults for users that have set an account value for: QUOTED_IDENTIFIERS_IGNORE_CASE +you can learn more about this here: https://docs.snowflake.com/en/sql-reference/identifiers-syntax#double-quoted-identifiers + ## Setup ### Manual diff --git a/packages/cubejs-snowflake-driver/src/SnowflakeDriver.ts b/packages/cubejs-snowflake-driver/src/SnowflakeDriver.ts index 97b11354fccc0..6daa1939692a6 100644 --- a/packages/cubejs-snowflake-driver/src/SnowflakeDriver.ts +++ b/packages/cubejs-snowflake-driver/src/SnowflakeDriver.ts @@ -22,7 +22,6 @@ import { DownloadQueryResultsResult, DownloadQueryResultsOptions, DriverCapabilities, - QueryTablesResult, } from '@cubejs-backend/base-driver'; import { formatToTimeZone } from 'date-fns-timezone'; import { Storage } from '@google-cloud/storage'; @@ -356,7 +355,14 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface { await this.execute(connection, 'ALTER SESSION SET TIMEZONE = \'UTC\'', [], false); await this.execute(connection, `ALTER SESSION SET STATEMENT_TIMEOUT_IN_SECONDS = ${this.config.executionTimeout}`, [], false); - + /** + * Because snowflake has an opinion about the shape of data returns over the api. + * we have to set this value to false in order for our schema requests to succeed. + * + * You can learn more here. + * https://docs.snowflake.com/en/sql-reference/identifiers-syntax#double-quoted-identifiers + */ + await this.execute(connection, 'ALTER SESSION SET QUOTED_IDENTIFIERS_IGNORE_CASE = FALSE', [], false); return connection; } catch (e) { this.connection = null;