From 28cb10c2aed277f859dbee022dd1afebf7bc69be Mon Sep 17 00:00:00 2001 From: schuemie Date: Wed, 25 Sep 2024 11:32:54 +0200 Subject: [PATCH] On Snowflake, fixed 'This session does not have a current schema' error when translating legacy `IF OBJECT_ID('tempdb..#table', 'U') IS NOT NULL DROP TABLE #table;` --- NEWS.md | 4 ++++ inst/csv/replacementPatterns.csv | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 87ab02b..df1c9a7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,10 @@ Changes: 1. When creating emulated temp tables (Oracle, Spark, BigQuery), will first attempt to drop (if exist). This is to clean up any orphan tables from a previous (unsuccesful) run. +Bugfixes: + +1. On Snowflake, fixed 'This session does not have a current schema' error when translating legacy `IF OBJECT_ID('tempdb..#table', 'U') IS NOT NULL DROP TABLE #table;` + SqlRender 1.18.1 ================ diff --git a/inst/csv/replacementPatterns.csv b/inst/csv/replacementPatterns.csv index 11344e4..d9b5478 100644 --- a/inst/csv/replacementPatterns.csv +++ b/inst/csv/replacementPatterns.csv @@ -1326,7 +1326,7 @@ snowflake,COUNT_BIG(@a),COUNT(@a) snowflake,NEWID(),UUID_STRING() snowflake,"IF OBJECT_ID('@table', 'U') IS NULL CREATE TABLE @table (@definition);",CREATE TABLE IF NOT EXISTS @table (@definition); snowflake,"IF OBJECT_ID('@table', 'U') IS NOT NULL DROP TABLE @table;",DROP TABLE IF EXISTS @table; -snowflake,"IF OBJECT_ID('tempdb..#@table', 'U') IS NOT NULL DROP TABLE #@table;",DROP TABLE IF EXISTS @table; +snowflake,"IF OBJECT_ID('tempdb..#@table', 'U') IS NOT NULL DROP TABLE #@table;",DROP TABLE IF EXISTS #@table; snowflake,.dbo.,. snowflake,CREATE TABLE #@table (@definition),CREATE TEMP TABLE #@table (@definition) snowflake,CREATE CLUSTERED INDEX @index_name ON @table (@variable);,-- snowflake does not support indexes