All Questions
Tagged with snowflake-cloud-data-platform sql
3,679
questions
0
votes
1
answer
39
views
Restructuring actions table into a daily snapshot view
Assuming the default status is always "Released" and given a table that contains history of actions taken:
I'd like to have this to be expanded to a daily snapshot view (last month only) ...
1
vote
0
answers
71
views
Apply large number of decision tree rules to SQL data
I want to apply rules that I've created from modelling on data using a decision tree to unseen data. I've parsed the rules to get a CASE WHEN statement like so:
CASE
WHEN variable_1 = "Value1&...
1
vote
1
answer
44
views
Snowflake unsupported subquery type for UDTF
In Snowflake, I'm trying to save a large amount of code size and maintenance by creating a UDTF to show flags for each row v based on presence of rows in x or y meeting some pattern.
The error I get ...
0
votes
2
answers
51
views
DBT Duplicate row detected during DML action - Snowflake
Creating an incremental model using the MERGE strategy with a unique key. The unique key to merge on is a surrogate key of columns from the table.
When I run this incremental model I get the error: ...
1
vote
1
answer
31
views
Snowflake Native app with container service, grant imported privilege on Snowflake DB
How can a snowflake native application built with container services request or grant imported privilege on Snowflake DB?
According to Snowflake Documentation, the grant can only be added through SQL ...
0
votes
1
answer
37
views
Snowflake SQL. Select column value if 1st 5 characters are numeric and within a Numeric Range
I have a column named ProcedureCode VARCHAR(16777216) in a Table named ProcedureCode.
It has values like '12345,46H', 'A4715,12W', '98765', '99200' etc.
From that Table, I need to pull only rows where ...
1
vote
1
answer
61
views
Create a Sql Statement IN DBT macro and use the query in the dbt model
my_macro.sql
{macro my_macro(value)}
{% set query %}
select A from value
{{ return(query) }}
{% endset %}
{% endmacro %}
model.sql
select * from B
where A in ({{ my_macro(value) }}
when i ...
-1
votes
1
answer
25
views
how to get history of the snowflake table and how to get what is the version of the snowflake table and operation of the snowflake table as well
select max(timestamp) from (DESCRIBE HISTORY <tablename> ) where operation = 'MERGE'
DESCRIBE HISTORY <tablename> ).orderBy(col("version").desc).first.getLong(0)
I need to ...
0
votes
2
answers
67
views
Dynamic inputs to Date calendar CTE in Snowflake SQL
In Snowflake, how can I declare variables to make the this CTE calendar table dynamic?
The below works if I hardcode the start_date and day_count params, but I'd like to make it more dynamic.
SET '...
0
votes
1
answer
43
views
Left join later flatten works not like left join, but the same as inner join
With this data:
create or replace table test_json as
select
parse_json('{
"include": [
"x",
"y",
"z"
...
0
votes
1
answer
31
views
How can i find out records from a column in a table in Snowflake which does not have any alphabets as well any number?
I have a table and within that in a specific column, i need to find out the records which are having characters anything except an alphabets or numbers.
I tried using regex as
'[^A-Za-z0-9 ]'
Am i ...
0
votes
0
answers
41
views
Converting basic update logic from a table to a view in Snowflake
I'm working on converting something that's currently in a table in snowflake into a view. One of the big issues I've run into is that the code I was provided to build the table uses the SQL UPDATE ...
0
votes
0
answers
42
views
Is there a way to optimize this query in Tsql?
WITH CTE AS
(
WITH flattened_data AS
(
SELECT
DISTINCT
MAX(CASE WHEN (entry.value:Id::STRING)='123' THEN entry.value:Answer:text::STRING END) AS VD,
MAX(CASE WHEN (...
0
votes
0
answers
45
views
creating a data dictionary via snowflake query?
I figured I could easily create a basic data dictionary of the schema my team is working out of. I currently have this:
WITH column_metadata AS (
SELECT
TABLE_SCHEMA,
TABLE_NAME,
...
0
votes
0
answers
37
views
Iterating through tables/columns in snowflake schema to find text value only working sometimes?
I am working within a snowflake DB schema that has about 200 tables and I need to figure out which table has a specific row-level value within a column. Looking for any table that contains a value = &...