From f66d967ea885412168e993ee266e99522407d636 Mon Sep 17 00:00:00 2001 From: Peter Kosztolanyi Date: Mon, 3 Aug 2020 15:51:55 +0200 Subject: [PATCH] [AP-824] Set QUOTED_IDENTIFIERS_IGNORE_CASE session parameter to false (#94) --- target_snowflake/db_sync.py | 6 +++++- tests/integration/test_target_snowflake.py | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/target_snowflake/db_sync.py b/target_snowflake/db_sync.py index 36c636b5..b844b610 100644 --- a/target_snowflake/db_sync.py +++ b/target_snowflake/db_sync.py @@ -323,7 +323,11 @@ def open_connection(self): account=self.connection_config['account'], database=self.connection_config['dbname'], warehouse=self.connection_config['warehouse'], - autocommit=True + autocommit=True, + session_parameters={ + # Quoted identifiers should be case sensitive + 'QUOTED_IDENTIFIERS_IGNORE_CASE': 'FALSE' + } ) def query(self, query, params=None, max_records=0): diff --git a/tests/integration/test_target_snowflake.py b/tests/integration/test_target_snowflake.py index 0866ae5b..ac6c24db 100644 --- a/tests/integration/test_target_snowflake.py +++ b/tests/integration/test_target_snowflake.py @@ -1021,3 +1021,22 @@ def test_loading_tables_with_no_compression(self): self.persist_lines_with_cache(tap_lines) self.assert_three_streams_are_into_snowflake() + + def test_quoted_identifiers_ignore_case_session_parameter(self): + """Test if QUOTED_IDENTIFIERS_IGNORE_CASE session parameter set to FALSE""" + snowflake = DbSync(self.config) + + # Set QUOTED_IDENTIFIERS_IGNORE_CASE to True on user level + snowflake.query(f"ALTER USER {self.config['user']} SET QUOTED_IDENTIFIERS_IGNORE_CASE = TRUE") + + # Quoted column names should be case sensitive even if the + # QUOTED_IDENTIFIERS_IGNORE_CASE parameter set to TRUE on user or account level + result = snowflake.query('SELECT 1 AS "Foo", 1 AS "foo", 1 AS "FOO", 1 AS foo, 1 AS FOO') + self.assertEqual(result, [{ + 'Foo': 1, + 'foo': 1, + 'FOO': 1 + }]) + + # Reset parameters default + snowflake.query(f"ALTER USER {self.config['user']} UNSET QUOTED_IDENTIFIERS_IGNORE_CASE")