snowflake-cloud-data-platform

How to Commit/Rollback stored procedure based on return value in Snowflake?

雨燕双飞 提交于 2020-06-17 13:07:08
问题 I have a javascript stored procedure that return boolean. I want to be able to call this stored procedure inside a transaction and test the return value before committing the transaction. BEGIN; SET result = CALL my_stored_proc(); IF $result = true COMMIT; ELSE ROLLBACK; The stored procedure will return false if there is an exception or if there is some missing values based on business logic. How do I achieve this in Snowflake? EDIT: I tried the following and it did not work. The transaction

CONV() function in snowflake

强颜欢笑 提交于 2020-06-09 05:21:12
问题 I'm trying to find equivalent of the CONV() MySQL function in Snowflake, but I can't seem find it. I'm trying to do the following in Snowflake: SELECT CONV('39ix75wf3aor7',36,10) The result should be 15468921890196183763 回答1: I wrote a UDF to do what CONV() does. It works, but unfortunately Javascript variables don't support numeric precision for as large as your sample. This will work for smaller inputs, but for your large Base36 input the following happens: 15468921890196183763 --should be

CONV() function in snowflake

你离开我真会死。 提交于 2020-06-09 05:20:59
问题 I'm trying to find equivalent of the CONV() MySQL function in Snowflake, but I can't seem find it. I'm trying to do the following in Snowflake: SELECT CONV('39ix75wf3aor7',36,10) The result should be 15468921890196183763 回答1: I wrote a UDF to do what CONV() does. It works, but unfortunately Javascript variables don't support numeric precision for as large as your sample. This will work for smaller inputs, but for your large Base36 input the following happens: 15468921890196183763 --should be

Snowflake Flatten Query for array

怎甘沉沦 提交于 2020-06-01 05:09:06
问题 Snowflake Table has 1 Variant column and loaded with 3 JSON record. The JSON records is as follows. {"address":{"City":"Lexington","Address1":"316 Tarrar Springs Rd","Address2":null} {"address":{"City":"Hartford","Address1":"318 Springs Rd","Address2":"319 Springs Rd"} {"address":{"City":"Avon","Address1":"38 Springs Rd","Address2":[{"txtvalue":null},{"txtvalue":"Line 1"},{"Line1":"Line 1"}]} If you look at the Address2 field in the JSON , The first one holds NULL,2nd String and 3rd one array

Snowflake - Privileges required to query snowflake Information schema views

痴心易碎 提交于 2020-05-17 08:19:05
问题 I am new to Snowflake. Is it possible to query Information schema views for eg, SCHEMATA, TABLES, COLUMNS for all tables in a snowflake Db without having select access to the underlying tables. The requirement is to create a user/account that only has access to query metadata of the snowflake Db and should not have a select access to the table data. Please advise. 回答1: From the Snowflake documentation: "The output of a view or table function depends on the privileges granted to the user’s

Lateral Flatten Snowpipe data with mixture of arrays and dict

泪湿孤枕 提交于 2020-04-18 05:27:42
问题 I have two different structured json files being piped in from a snowpipe. The only difference is that instead of a nested dict it has many nested arrays. I am trying to figure out how to transform structure 1 into one finalized table. I've successfully transformed structure 2 into a table and included the code below. I know I need to be making use of lateral flatten but have not been successful. **Structure 1: Nested Arrays (Need help on)** This json lives within a table and in column *

How to drop temp tables created in snowflake

梦想与她 提交于 2020-04-17 21:30:45
问题 I am loading data through ODI into snowflake temp tables created with c$ needs to be dropped after load successful,how to drop those temp tables appreciate your suggestion 回答1: If you still need this, I wrote a stored procedure that will take a list of SQL generated dynamically and execute the lines one at a time. You can use it to run any list of generated SQL statements resulting from a select query, including dropping all tables matching a pattern such as c$%. First, here's the stored

How to drop temp tables created in snowflake

送分小仙女□ 提交于 2020-04-17 21:30:37
问题 I am loading data through ODI into snowflake temp tables created with c$ needs to be dropped after load successful,how to drop those temp tables appreciate your suggestion 回答1: If you still need this, I wrote a stored procedure that will take a list of SQL generated dynamically and execute the lines one at a time. You can use it to run any list of generated SQL statements resulting from a select query, including dropping all tables matching a pattern such as c$%. First, here's the stored

COPY INTO Snowflake Table with Extra Columns

 ̄綄美尐妖づ 提交于 2020-04-16 13:53:48
问题 I've got a table defined in Snowflake as: GLPCT BATCH_KEY NUMBER(38,0) NULL CTACCT VARCHAR(100) NULL CTPAGE NUMBER(38,0) NULL and a file that looks like this: GLPCT.csv CTACCT VARCHAR(100) CTPAGE NUMBER(38,0) example: CTACCT,CTPAGE "Test Account",100 "Second Account", 200 My copy into command looks like this: copy into GLPCT_POC from 'azure://ouraccount.blob.core.windows.net/landing/GLPCT' credentials=(azure_sas_token='<SAS_TOKEN') file_format=(TYPE=CSV, SKIP_HEADER = 1, FIELD_OPTIONALLY

COPY INTO Snowflake Table with Extra Columns

血红的双手。 提交于 2020-04-16 13:52:43
问题 I've got a table defined in Snowflake as: GLPCT BATCH_KEY NUMBER(38,0) NULL CTACCT VARCHAR(100) NULL CTPAGE NUMBER(38,0) NULL and a file that looks like this: GLPCT.csv CTACCT VARCHAR(100) CTPAGE NUMBER(38,0) example: CTACCT,CTPAGE "Test Account",100 "Second Account", 200 My copy into command looks like this: copy into GLPCT_POC from 'azure://ouraccount.blob.core.windows.net/landing/GLPCT' credentials=(azure_sas_token='<SAS_TOKEN') file_format=(TYPE=CSV, SKIP_HEADER = 1, FIELD_OPTIONALLY