├── snowflake.gif ├── src ├── main │ ├── resources │ │ ├── log4j.properties │ │ ├── snowflake-layout.json │ │ ├── sabot-module.conf │ │ ├── SNOWFLAKE.svg │ │ └── arp │ │ │ └── implementation │ │ │ └── snowflake-arp.yaml │ ├── checkstyle │ │ ├── checkstyle-suppresions.xml │ │ └── checkstyle-config.xml │ └── java │ │ └── com │ │ └── dremio │ │ └── exec │ │ └── store │ │ └── jdbc │ │ └── conf │ │ └── SnowflakeConf.java └── test │ ├── resources │ ├── output.csv │ └── DDL.sql │ └── java │ └── com │ └── dremio │ └── snowflake │ └── SnowflakeTest.java ├── .github ├── ISSUE_TEMPLATE │ ├── enhancement.md │ └── bug-report.md └── workflows │ └── main.yml ├── tpch ├── q6.sql ├── q17.sql ├── q14.sql ├── q4.sql ├── q3.sql ├── q13.sql ├── q1.sql ├── q5.sql ├── q18.sql ├── q16.sql ├── q11.sql ├── q10.sql ├── q12.sql ├── q15.sql ├── q9.sql ├── q20.sql ├── q21.sql ├── q22.sql ├── q2.sql ├── q8.sql ├── q7.sql └── q19.sql ├── .gitignore ├── docker └── Dockerfile ├── pom.xml ├── README.md └── LICENSE /snowflake.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narendrans/dremio-snowflake/HEAD/snowflake.gif -------------------------------------------------------------------------------- /src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 2 | log4j.appender.stdout.Target=System.out 3 | log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout 4 | log4j.rootLogger=info, stdout -------------------------------------------------------------------------------- /src/test/resources/output.csv: -------------------------------------------------------------------------------- 1 | A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X 2 | 123,334,55,555,3934,123,2.12,45.22,9.2,123.12,9.12,92.12,q,a,dremio,Dremio data as a service,534E4F57,534E4F57,2018-02-20 00:00:00.000,00:00:00,2018-02-20 00:00:00.000,2018-02-20 00:00:00.000 -0800,2018-02-20 00:00:00.000,2018-02-20 00:00:00.000 -0800 -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/enhancement.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Enhancement Request 3 | about: Suggest an enhancement to the Snowflake connector project 4 | labels: kind/feature 5 | 6 | --- 7 | 8 | 9 | **What would you like to be added**: 10 | 11 | **Why is this needed**: 12 | -------------------------------------------------------------------------------- /tpch/q6.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | sum(l_extendedprice * l_discount) as revenue 4 | from 5 | "lineitem" 6 | where 7 | l_shipdate >= date '1997-01-01' 8 | and l_shipdate < date '1997-01-01' + interval '1' year 9 | and 10 | l_discount between 0.03 - 0.01 and 0.03 + 0.01 11 | and l_quantity < 24 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | 25 | # IntelliJ 26 | *.iml 27 | 28 | # Builds 29 | target/ 30 | 31 | # Mac 32 | .DS_Store 33 | .idea 34 | -------------------------------------------------------------------------------- /tpch/q17.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | sum(l.l_extendedprice) / 7.0 as avg_yearly 4 | from 5 | "lineitem" l, 6 | "part" p 7 | where 8 | p.p_partkey = l.l_partkey 9 | and p.p_brand = 'Brand#13' 10 | and p.p_container = 'JUMBO CAN' 11 | and l.l_quantity < ( 12 | select 13 | 0.2 * avg(l2.l_quantity) 14 | from 15 | "lineitem" l2 16 | where 17 | l2.l_partkey = p.p_partkey 18 | ) -------------------------------------------------------------------------------- /tpch/q14.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | 100.00 * sum(case 4 | when p.p_type like 'PROMO%' 5 | then l.l_extendedprice * (1 - l.l_discount) 6 | else 0 7 | end) / sum(l.l_extendedprice * (1 - l.l_discount)) as promo_revenue 8 | from 9 | "lineitem" l, 10 | "part" p 11 | where 12 | l.l_partkey = p.p_partkey 13 | and l.l_shipdate >= date '1994-08-01' 14 | and l.l_shipdate < date '1994-08-01' + interval '1' month -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Report a bug encountered while using Snowflake Connector 4 | labels: kind/bug 5 | --- 6 | 7 | 8 | 9 | 10 | **What happened**: 11 | 12 | **What you expected to happen**: 13 | 14 | **How to reproduce it (as minimally and precisely as possible)**: 15 | 16 | **Anything else we need to know?**: 17 | 18 | **Details**: 19 | - Dremio version (Help > About from the UI): 20 | - Profile zip: 21 | - server.log: 22 | -------------------------------------------------------------------------------- /tpch/q4.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | o.o_orderpriority, 4 | count(*) as order_count 5 | from 6 | "orders" o 7 | where 8 | o.o_orderdate >= date '1996-10-01' 9 | and o.o_orderdate < date '1996-10-01' + interval '3' month 10 | and 11 | exists ( 12 | select 13 | * 14 | from 15 | "lineitem" l 16 | where 17 | l.l_orderkey = o.o_orderkey 18 | and l.l_commitdate < l.l_receiptdate 19 | ) 20 | group by 21 | o.o_orderpriority 22 | order by 23 | o.o_orderpriority -------------------------------------------------------------------------------- /src/main/resources/snowflake-layout.json: -------------------------------------------------------------------------------- 1 | { 2 | "sourceType": "SNOWFLAKE", 3 | "metadataRefresh": { 4 | "datasetDiscovery": true 5 | }, 6 | "form": { 7 | "tabs": [ 8 | { 9 | "name": "General", 10 | "isGeneral": true, 11 | "sections": [ 12 | { 13 | "name": "Snowflake Source", 14 | "layout": "row", 15 | "elements": [ 16 | { 17 | "propName": "config.enableExternalQuery" 18 | } 19 | ] 20 | } 21 | ] 22 | } 23 | ] 24 | } 25 | } -------------------------------------------------------------------------------- /tpch/q3.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | l.l_orderkey, 4 | sum(l.l_extendedprice * (1 - l.l_discount)) as revenue, 5 | o.o_orderdate, 6 | o.o_shippriority 7 | 8 | from 9 | "customer" c, 10 | "orders" o, 11 | "lineitem" l 12 | 13 | where 14 | c.c_mktsegment = 'HOUSEHOLD' 15 | and c.c_custkey = o.o_custkey 16 | and l.l_orderkey = o.o_orderkey 17 | and o.o_orderdate < date '1995-03-25' 18 | and l.l_shipdate > date '1995-03-25' 19 | 20 | group by 21 | l.l_orderkey, 22 | o.o_orderdate, 23 | o.o_shippriority 24 | order by 25 | revenue desc, 26 | o.o_orderdate 27 | limit 10 -------------------------------------------------------------------------------- /tpch/q13.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | 3 | select 4 | c_count, 5 | count(*) as custdist 6 | from 7 | ( 8 | select 9 | c.c_custkey, 10 | count(o.o_orderkey) 11 | from 12 | customer c 13 | left outer join orders o 14 | on c.c_custkey = o.o_custkey 15 | and o.o_comment not like '%special%requests%' 16 | group by 17 | c.c_custkey 18 | ) as orders (c_custkey, c_count) 19 | group by 20 | c_count 21 | order by 22 | custdist desc, 23 | c_count desc; -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM dremio/dremio-oss:17.0.0 2 | USER root 3 | 4 | WORKDIR /tmp 5 | 6 | RUN wget http://apache.osuosl.org/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.zip && \ 7 | unzip apache-maven-3.6.1-bin.zip && \ 8 | git clone https://github.com/narendrans/dremio-snowflake.git && cd dremio-snowflake && \ 9 | export PATH=$PATH:/tmp/apache-maven-3.6.1/bin && \ 10 | mvn clean install -DskipTests && \ 11 | cp target/dremio-snowflake*.jar /opt/dremio/jars && \ 12 | cd /opt/dremio/jars && wget https://repo1.maven.org/maven2/net/snowflake/snowflake-jdbc/3.13.5/snowflake-jdbc-3.13.5.jar && \ 13 | chown dremio *snowflake*.jar && rm -rf ~/.m2 && rm -rf /tmp/* 14 | 15 | WORKDIR /opt/dremio 16 | USER dremio 17 | -------------------------------------------------------------------------------- /tpch/q1.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | l_returnflag, 4 | l_linestatus, 5 | sum(l_quantity) as sum_qty, 6 | sum(l_extendedprice) as sum_base_price, 7 | sum(l_extendedprice * (1 - l_discount)) as sum_disc_price, 8 | sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge, 9 | avg(l_quantity) as avg_qty, 10 | avg(l_extendedprice) as avg_price, 11 | avg(l_discount) as avg_disc, 12 | count(*) as count_order 13 | from 14 | lineitem 15 | where 16 | l_shipdate <= date '1998-12-01' - interval '120' day (3) 17 | group by 18 | l_returnflag, 19 | l_linestatus 20 | order by 21 | l_returnflag, 22 | l_linestatus -------------------------------------------------------------------------------- /tpch/q5.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | n.n_name, 4 | sum(l.l_extendedprice * (1 - l.l_discount)) as revenue 5 | from 6 | "customer" c, 7 | "orders" o, 8 | "lineitem" l, 9 | "supplier" s, 10 | "nation" n, 11 | "region" r 12 | where 13 | c.c_custkey = o.o_custkey 14 | and l.l_orderkey = o.o_orderkey 15 | and l.l_suppkey = s.s_suppkey 16 | and c.c_nationkey = s.s_nationkey 17 | and s.s_nationkey = n.n_nationkey 18 | and n.n_regionkey = r.r_regionkey 19 | and r.r_name = 'EUROPE' 20 | and o.o_orderdate >= date '1997-01-01' 21 | and o.o_orderdate < date '1997-01-01' + interval '1' year 22 | group by 23 | n.n_name 24 | order by 25 | revenue desc -------------------------------------------------------------------------------- /tpch/q18.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | c.c_name, 4 | c.c_custkey, 5 | o.o_orderkey, 6 | o.o_orderdate, 7 | o.o_totalprice, 8 | sum(l.l_quantity) 9 | from 10 | "customer" c, 11 | "orders" o, 12 | "lineitem" l 13 | where 14 | o.o_orderkey in ( 15 | select 16 | l_orderkey 17 | from 18 | "lineitem" 19 | group by 20 | l_orderkey having 21 | sum(l_quantity) > 300 22 | ) 23 | and c.c_custkey = o.o_custkey 24 | and o.o_orderkey = l.l_orderkey 25 | group by 26 | c.c_name, 27 | c.c_custkey, 28 | o.o_orderkey, 29 | o.o_orderdate, 30 | o.o_totalprice 31 | order by 32 | o.o_totalprice desc, 33 | o.o_orderdate 34 | limit 100 -------------------------------------------------------------------------------- /tpch/q16.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | p.p_brand, 4 | p.p_type, 5 | p.p_size, 6 | count(distinct ps.ps_suppkey) as supplier_cnt 7 | from 8 | "partsupp" ps, 9 | "part" p 10 | where 11 | p.p_partkey = ps.ps_partkey 12 | and p.p_brand <> 'Brand#21' 13 | and p.p_type not like 'MEDIUM PLATED%' 14 | and p.p_size in (38, 2, 8, 31, 44, 5, 14, 24) 15 | and ps.ps_suppkey not in ( 16 | select 17 | s.s_suppkey 18 | from 19 | "supplier" s 20 | where 21 | s.s_comment like '%Customer%Complaints%' 22 | ) 23 | group by 24 | p.p_brand, 25 | p.p_type, 26 | p.p_size 27 | order by 28 | supplier_cnt desc, 29 | p.p_brand, 30 | p.p_type, 31 | p.p_size -------------------------------------------------------------------------------- /src/test/resources/DDL.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE TABLE "DEMO_DB"."PUBLIC"."all_types" (a DECIMAL, 2 | b NUMERIC, 3 | c INT, 4 | d INTEGER, 5 | e BIGINT, 6 | f SMALLINT, 7 | g FLOAT, 8 | h FLOAT4, 9 | i FLOAT8, 10 | j DOUBLE, 11 | k DOUBLE PRECISION, 12 | l REAL, 13 | m CHAR, 14 | n CHARACTER, 15 | o STRING, 16 | p TEXT, 17 | q BINARY, 18 | r VARBINARY, 19 | s DATETIME, 20 | t TIME, 21 | u TIMESTAMP); 22 | 23 | INSERT INTO "DEMO_DB"."PUBLIC"."all_types" VALUES ( 24 | 1, 25 | 334, 26 | 55, 27 | 555, 28 | 3934, 29 | 929, 30 | 2.12, 31 | 45.22, 32 | 9.2, 33 | 123.12, 34 | 9.12, 35 | 92.12, 36 | 'q', 37 | 'a', 38 | 'dremio', 39 | 'Dremio data as a service', 40 | to_binary('SNOW', 'utf-8'), 41 | to_binary('SNOW', 'utf-8'), 42 | '2018-02-20 00:00:00.000', 43 | '00:00:00.000', 44 | '2018-02-20 00:00:00.000'); -------------------------------------------------------------------------------- /tpch/q11.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | ps.ps_partkey, 4 | sum(ps.ps_supplycost * ps.ps_availqty) as "value" 5 | from 6 | "partsupp" ps, 7 | "supplier" s, 8 | "nation" n 9 | where 10 | ps.ps_suppkey = s.s_suppkey 11 | and s.s_nationkey = n.n_nationkey 12 | and n.n_name = 'JAPAN' 13 | group by 14 | ps.ps_partkey having 15 | sum(ps.ps_supplycost * ps.ps_availqty) > ( 16 | select 17 | sum(ps.ps_supplycost * ps.ps_availqty) * 0.0001000000 18 | from 19 | "partsupp" ps, 20 | "supplier" s, 21 | "nation" n 22 | where 23 | ps.ps_suppkey = s.s_suppkey 24 | and s.s_nationkey = n.n_nationkey 25 | and n.n_name = 'JAPAN' 26 | ) 27 | order by 28 | "value" desc -------------------------------------------------------------------------------- /tpch/q10.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | c.c_custkey, 4 | c.c_name, 5 | sum(l.l_extendedprice * (1 - l.l_discount)) as revenue, 6 | c.c_acctbal, 7 | n.n_name, 8 | c.c_address, 9 | c.c_phone, 10 | c.c_comment 11 | from 12 | "customer" c, 13 | "orders" o, 14 | "lineitem" l, 15 | "nation" n 16 | where 17 | c.c_custkey = o.o_custkey 18 | and l.l_orderkey = o.o_orderkey 19 | and o.o_orderdate >= date '1994-03-01' 20 | and o.o_orderdate < date '1994-03-01' + interval '3' month 21 | and l.l_returnflag = 'R' 22 | and c.c_nationkey = n.n_nationkey 23 | group by 24 | c.c_custkey, 25 | c.c_name, 26 | c.c_acctbal, 27 | c.c_phone, 28 | n.n_name, 29 | c.c_address, 30 | c.c_comment 31 | order by 32 | revenue desc 33 | limit 20 -------------------------------------------------------------------------------- /tpch/q12.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | l.l_shipmode, 4 | sum(case 5 | when o.o_orderpriority = '1-URGENT' 6 | or o.o_orderpriority = '2-HIGH' 7 | then 1 8 | else 0 9 | end) as high_line_count, 10 | sum(case 11 | when o.o_orderpriority <> '1-URGENT' 12 | and o.o_orderpriority <> '2-HIGH' 13 | then 1 14 | else 0 15 | end) as low_line_count 16 | from 17 | "orders" o, 18 | "lineitem" l 19 | where 20 | o.o_orderkey = l.l_orderkey 21 | and l.l_shipmode in ('TRUCK', 'REG AIR') 22 | and l.l_commitdate < l.l_receiptdate 23 | and l.l_shipdate < l.l_commitdate 24 | and l.l_receiptdate >= date '1994-01-01' 25 | and l.l_receiptdate < date '1994-01-01' + interval '1' year 26 | group by 27 | l.l_shipmode 28 | order by 29 | l.l_shipmode -------------------------------------------------------------------------------- /tpch/q15.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | -- Create a data set in Dremio and use it as such... (create view is not supported) 3 | 4 | create view revenue0 (supplier_no, total_revenue) as 5 | select 6 | l_suppkey, 7 | sum(l_extendedprice * (1 - l_discount)) 8 | from 9 | lineitem 10 | where 11 | l_shipdate >= date '1993-05-01' 12 | and l_shipdate < date '1993-05-01' + interval '3' month 13 | group by 14 | l_suppkey; 15 | 16 | select 17 | s.s_suppkey, 18 | s.s_name, 19 | s.s_address, 20 | s.s_phone, 21 | r.total_revenue 22 | from 23 | cp."tpch/supplier.parquet" s, 24 | revenue0 r 25 | where 26 | s.s_suppkey = r.supplier_no 27 | and r.total_revenue = ( 28 | select 29 | max(total_revenue) 30 | from 31 | revenue0 32 | ) 33 | order by 34 | s.s_suppkey; 35 | 36 | drop view revenue0; -------------------------------------------------------------------------------- /tpch/q9.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | nation, 4 | o_year, 5 | sum(amount) as sum_profit 6 | from 7 | ( 8 | select 9 | n.n_name as nation, 10 | extract(year from o.o_orderdate) as o_year, 11 | l.l_extendedprice * (1 - l.l_discount) - ps.ps_supplycost * l.l_quantity as amount 12 | from 13 | "part" p, 14 | "supplier" s, 15 | "lineitem" l, 16 | "partsupp" ps, 17 | "orders" o, 18 | "nation" n 19 | where 20 | s.s_suppkey = l.l_suppkey 21 | and ps.ps_suppkey = l.l_suppkey 22 | and ps.ps_partkey = l.l_partkey 23 | and p.p_partkey = l.l_partkey 24 | and o.o_orderkey = l.l_orderkey 25 | and s.s_nationkey = n.n_nationkey 26 | and p.p_name like '%yellow%' 27 | ) as profit 28 | group by 29 | nation, 30 | o_year 31 | order by 32 | nation, 33 | o_year desc -------------------------------------------------------------------------------- /tpch/q20.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | s.s_name, 4 | s.s_address 5 | from 6 | "supplier" s, 7 | "nation" n 8 | where 9 | s.s_suppkey in ( 10 | select 11 | ps.ps_suppkey 12 | from 13 | "partsupp" ps 14 | where 15 | ps. ps_partkey in ( 16 | select 17 | p.p_partkey 18 | from 19 | "part" p 20 | where 21 | p.p_name like 'antique%' 22 | ) 23 | and ps.ps_availqty > ( 24 | select 25 | 0.5 * sum(l.l_quantity) 26 | from 27 | "lineitem" l 28 | where 29 | l.l_partkey = ps.ps_partkey 30 | and l.l_suppkey = ps.ps_suppkey 31 | and l.l_shipdate >= date '1993-01-01' 32 | and l.l_shipdate < date '1993-01-01' + interval '1' year 33 | ) 34 | ) 35 | and s.s_nationkey = n.n_nationkey 36 | and n.n_name = 'KENYA' 37 | order by 38 | s.s_name -------------------------------------------------------------------------------- /tpch/q21.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | s.s_name, 4 | count(*) as numwait 5 | from 6 | "supplier" s, 7 | "lineitem" l1, 8 | "orders" o, 9 | "nation" n 10 | where 11 | s.s_suppkey = l1.l_suppkey 12 | and o.o_orderkey = l1.l_orderkey 13 | and o.o_orderstatus = 'F' 14 | and l1.l_receiptdate > l1.l_commitdate 15 | and exists ( 16 | select 17 | * 18 | from 19 | "lineitem" l2 20 | where 21 | l2.l_orderkey = l1.l_orderkey 22 | and l2.l_suppkey <> l1.l_suppkey 23 | ) 24 | and not exists ( 25 | select 26 | * 27 | from 28 | "lineitem" l3 29 | where 30 | l3.l_orderkey = l1.l_orderkey 31 | and l3.l_suppkey <> l1.l_suppkey 32 | and l3.l_receiptdate > l3.l_commitdate 33 | ) 34 | and s.s_nationkey = n.n_nationkey 35 | and n.n_name = 'BRAZIL' 36 | group by 37 | s.s_name 38 | order by 39 | numwait desc, 40 | s.s_name 41 | limit 100 -------------------------------------------------------------------------------- /src/main/resources/sabot-module.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2017-2019 Dremio Corporation 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | // This file tells Dremio to consider this module when class path scanning. 18 | // This file can also include any supplementary configuration information. 19 | // This file is in HOCON format, see https://github.com/typesafehub/config/blob/master/HOCON.md for more information. 20 | dremio.classpath.scanning.packages += "com.dremio.exec.store.jdbc" 21 | 22 | -------------------------------------------------------------------------------- /src/main/checkstyle/checkstyle-suppresions.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /tpch/q22.sql: -------------------------------------------------------------------------------- 1 | select 2 | cntrycode, 3 | count(*) as numcust, 4 | sum(c_acctbal) as totacctbal 5 | from 6 | ( 7 | select 8 | substring(c_phone from 1 for 2) as cntrycode, 9 | c_acctbal 10 | from 11 | customer 12 | where 13 | substring(c_phone from 1 for 2) in 14 | ('30', '24', '31', '38', '25', '34', '37') 15 | and c_acctbal > ( 16 | select 17 | avg(c_acctbal) 18 | from 19 | customer 20 | where 21 | c_acctbal > 0.00 22 | and substring(c_phone from 1 for 2) in 23 | ('30', '24', '31', '38', '25', '34', '37') 24 | ) 25 | and not exists ( 26 | select 27 | * 28 | from 29 | orders 30 | where 31 | o_custkey = c_custkey 32 | ) 33 | ) as custsale 34 | group by 35 | cntrycode 36 | order by 37 | cntrycode -------------------------------------------------------------------------------- /tpch/q2.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | 3 | select 4 | s.s_acctbal, 5 | s.s_name, 6 | n.n_name, 7 | p.p_partkey, 8 | p.p_mfgr, 9 | s.s_address, 10 | s.s_phone, 11 | s.s_comment 12 | from 13 | "part" p, 14 | "supplier" s, 15 | "partsupp" ps, 16 | "nation" n, 17 | "region" r 18 | where 19 | p.p_partkey = ps.ps_partkey 20 | and s.s_suppkey = ps.ps_suppkey 21 | and p.p_size = 41 22 | and p.p_type like '%NICKEL' 23 | and s.s_nationkey = n.n_nationkey 24 | and n.n_regionkey = r.r_regionkey 25 | and r.r_name = 'EUROPE' 26 | and ps.ps_supplycost = ( 27 | 28 | select 29 | min(ps.ps_supplycost) 30 | 31 | from 32 | "partsupp" ps, 33 | "supplier" s, 34 | "nation" n, 35 | "region" r 36 | where 37 | p.p_partkey = ps.ps_partkey 38 | and s.s_suppkey = ps.ps_suppkey 39 | and s.s_nationkey = n.n_nationkey 40 | and n.n_regionkey = r.r_regionkey 41 | and r.r_name = 'EUROPE' 42 | ) 43 | 44 | order by 45 | s.s_acctbal desc, 46 | n.n_name, 47 | s.s_name, 48 | p.p_partkey 49 | limit 100 -------------------------------------------------------------------------------- /tpch/q8.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | o_year, 4 | sum(case 5 | when nation = 'EGYPT' then volume 6 | else 0 7 | end) / sum(volume) as mkt_share 8 | from 9 | ( 10 | select 11 | extract(year from o.o_orderdate) as o_year, 12 | l.l_extendedprice * (1 - l.l_discount) as volume, 13 | n2.n_name as nation 14 | from 15 | "part" p, 16 | "supplier" s, 17 | "lineitem" l, 18 | "orders" o, 19 | "customer" c, 20 | "nation" n1, 21 | "nation" n2, 22 | "region" r 23 | where 24 | p.p_partkey = l.l_partkey 25 | and s.s_suppkey = l.l_suppkey 26 | and l.l_orderkey = o.o_orderkey 27 | and o.o_custkey = c.c_custkey 28 | and c.c_nationkey = n1.n_nationkey 29 | and n1.n_regionkey = r.r_regionkey 30 | and r.r_name = 'MIDDLE EAST' 31 | and s.s_nationkey = n2.n_nationkey 32 | and o.o_orderdate between date '1995-01-01' and date '1996-12-31' 33 | and p.p_type = 'PROMO BRUSHED COPPER' 34 | ) as all_nations 35 | group by 36 | o_year 37 | order by 38 | o_year -------------------------------------------------------------------------------- /tpch/q7.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | supp_nation, 4 | cust_nation, 5 | l_year, 6 | sum(volume) as revenue 7 | from 8 | ( 9 | select 10 | n1.n_name as supp_nation, 11 | n2.n_name as cust_nation, 12 | extract(year from l.l_shipdate) as l_year, 13 | l.l_extendedprice * (1 - l.l_discount) as volume 14 | from 15 | "supplier" s, 16 | "lineitem" l, 17 | "orders" o, 18 | "customer" c, 19 | "nation" n1, 20 | "nation" n2 21 | where 22 | s.s_suppkey = l.l_suppkey 23 | and o.o_orderkey = l.l_orderkey 24 | and c.c_custkey = o.o_custkey 25 | and s.s_nationkey = n1.n_nationkey 26 | and c.c_nationkey = n2.n_nationkey 27 | and ( 28 | (n1.n_name = 'EGYPT' and n2.n_name = 'UNITED STATES') 29 | or (n1.n_name = 'UNITED STATES' and n2.n_name = 'EGYPT') 30 | ) 31 | and l.l_shipdate between date '1995-01-01' and date '1996-12-31' 32 | ) as shipping 33 | group by 34 | supp_nation, 35 | cust_nation, 36 | l_year 37 | order by 38 | supp_nation, 39 | cust_nation, 40 | l_year -------------------------------------------------------------------------------- /tpch/q19.sql: -------------------------------------------------------------------------------- 1 | -- Taken from https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/test/resources/queries/tpch/ 2 | select 3 | sum(l.l_extendedprice* (1 - l.l_discount)) as revenue 4 | from 5 | "lineitem" l, 6 | "part" p 7 | where 8 | ( 9 | p.p_partkey = l.l_partkey 10 | and p.p_brand = 'Brand#41' 11 | and p.p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') 12 | and l.l_quantity >= 2 and l.l_quantity <= 2 + 10 13 | and p.p_size between 1 and 5 14 | and l.l_shipmode in ('AIR', 'AIR REG') 15 | and l.l_shipinstruct = 'DELIVER IN PERSON' 16 | ) 17 | or 18 | ( 19 | p.p_partkey = l.l_partkey 20 | and p.p_brand = 'Brand#13' 21 | and p.p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') 22 | and l.l_quantity >= 14 and l.l_quantity <= 14 + 10 23 | and p.p_size between 1 and 10 24 | and l.l_shipmode in ('AIR', 'AIR REG') 25 | and l.l_shipinstruct = 'DELIVER IN PERSON' 26 | ) 27 | or 28 | ( 29 | p.p_partkey = l.l_partkey 30 | and p.p_brand = 'Brand#55' 31 | and p.p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') 32 | and l.l_quantity >= 23 and l.l_quantity <= 23 + 10 33 | and p.p_size between 1 and 15 34 | and l.l_shipmode in ('AIR', 'AIR REG') 35 | and l.l_shipinstruct = 'DELIVER IN PERSON' 36 | ) -------------------------------------------------------------------------------- /src/main/checkstyle/checkstyle-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | workflow_dispatch: 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | - name: Set up JDK 1.8 16 | uses: actions/setup-java@v1 17 | with: 18 | java-version: 1.8 19 | - name: Install Dremio 20 | run: | 21 | cd /tmp && wget https://download.dremio.com/community-server/17.0.0-202107060524010627-31b5222b/dremio-community-17.0.0-202107060524010627-31b5222b.tar.gz 22 | mkdir /opt/dremio && tar xvf /tmp/dremio-community-17.0.0-202107060524010627-31b5222b.tar.gz -C /opt/dremio --strip-components=1 23 | - name: Build snowflake JAR 24 | run: | 25 | cd $GITHUB_WORKSPACE && mvn install -DskipTests && cp target/*.jar /opt/dremio/jars 26 | cd /opt/dremio/jars && wget https://repo1.maven.org/maven2/net/snowflake/snowflake-jdbc/3.13.5/snowflake-jdbc-3.13.5.jar 27 | - name: Start & wait for Dremio to be available 28 | run: | 29 | /opt/dremio/bin/dremio start 30 | until curl -Iks http://localhost:9047; do 31 | echo waiting for dremio 32 | sleep 1 33 | done 34 | curl 'http://localhost:9047/apiv2/bootstrap/firstuser' -X PUT -H 'Authorization: _dremionull' -H 'Content-Type: application/json' --data-binary '{"userName":"dremio","firstName":"dremio","lastName":"dremio","email":"dremio@dremio.com","createdAt":1557027923359,"password":"dremio123"}' --compressed 35 | cat /opt/dremio/log/server.out 36 | - name: Run unit tests 37 | env: 38 | SNOWFLAKE_JDBC_URL: ${{ secrets.SNOWFLAKE_JDBC_URL }} 39 | SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }} 40 | SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }} 41 | run: cd $GITHUB_WORKSPACE && mvn test 42 | -------------------------------------------------------------------------------- /src/main/resources/SNOWFLAKE.svg: -------------------------------------------------------------------------------- 1 | -icon-color -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 22 | 4.0.0 23 | 24 | com.dremio.plugins 25 | 23.0.1 26 | dremio-snowflake-plugin 27 | Dremio Snowflake Community Connector 28 | 29 | 30 | 23.0.1-202210141019030815-c1de8bcc 31 | 32 | 33 | 34 | 35 | com.dremio.community.plugins 36 | dremio-ce-jdbc-plugin 37 | ${dremio.version} 38 | 39 | 40 | 41 | com.dremio.distribution 42 | dremio-jdbc-driver 43 | ${dremio.version} 44 | 45 | 46 | 47 | net.snowflake 48 | snowflake-jdbc 49 | 3.13.5 50 | test 51 | 52 | 53 | 54 | junit 55 | junit 56 | 4.13.1 57 | test 58 | 59 | 60 | 61 | org.apache.httpcomponents 62 | httpclient 63 | 4.5.13 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | maven-compiler-plugin 72 | 3.0 73 | 74 | 1.8 75 | 1.8 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | dremio-public 84 | https://maven.dremio.com/public/ 85 | 86 | 87 | dremio-free 88 | https://maven.dremio.com/free/ 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /src/main/java/com/dremio/exec/store/jdbc/conf/SnowflakeConf.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017-2019 Dremio Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.dremio.exec.store.jdbc.conf; 18 | 19 | import static com.google.common.base.Preconditions.checkNotNull; 20 | 21 | import com.dremio.exec.store.jdbc.*; 22 | import com.dremio.options.OptionManager; 23 | import com.dremio.security.CredentialsService; 24 | import com.dremio.security.PasswordCredentials; 25 | import com.google.common.base.Strings; 26 | import org.apache.log4j.Logger; 27 | import com.dremio.exec.catalog.conf.DisplayMetadata; 28 | import com.dremio.exec.catalog.conf.NotMetadataImpacting; 29 | import com.dremio.exec.catalog.conf.Secret; 30 | import com.dremio.exec.catalog.conf.SourceType; 31 | import com.dremio.exec.store.jdbc.JdbcPluginConfig; 32 | import com.dremio.exec.store.jdbc.dialect.arp.ArpDialect; 33 | import com.dremio.exec.store.jdbc.dialect.arp.ArpYaml; 34 | import com.fasterxml.jackson.annotation.JsonIgnore; 35 | import com.google.common.annotations.VisibleForTesting; 36 | import io.protostuff.Tag; 37 | 38 | import java.io.IOException; 39 | import java.net.URI; 40 | import java.sql.SQLException; 41 | 42 | /** 43 | * Configuration for Snowflake. 44 | */ 45 | @SourceType(value = "SNOWFLAKE", label = "Snowflake", uiConfig = "snowflake-layout.json", externalQuerySupported = true) 46 | public class SnowflakeConf extends AbstractArpConf { 47 | 48 | private static final String ARP_FILENAME = "arp/implementation/snowflake-arp.yaml"; 49 | private static final ArpDialect ARP_DIALECT = 50 | AbstractArpConf.loadArpFile(ARP_FILENAME, (SnowflakeDialect::new)); 51 | private static final String DRIVER = "net.snowflake.client.jdbc.SnowflakeDriver"; 52 | private static Logger logger = Logger.getLogger(SnowflakeConf.class); 53 | 54 | static class SnowflakeSchemaFetcher extends JdbcSchemaFetcherImpl { 55 | 56 | public SnowflakeSchemaFetcher(JdbcPluginConfig config) { 57 | super(config); 58 | } 59 | 60 | protected boolean usePrepareForColumnMetadata() { 61 | return true; 62 | } 63 | } 64 | 65 | static class SnowflakeDialect extends ArpDialect { 66 | 67 | public SnowflakeDialect(ArpYaml yaml) { 68 | super(yaml); 69 | } 70 | 71 | @Override 72 | public JdbcSchemaFetcherImpl newSchemaFetcher(JdbcPluginConfig config) { 73 | return new SnowflakeSchemaFetcher(config); 74 | } 75 | 76 | public boolean supportsNestedAggregations() { 77 | return false; 78 | } 79 | } 80 | 81 | /* 82 | Check Snowflake JDBC connection docs for more details: https://docs.snowflake.net/manuals/user-guide/jdbc-configure.html 83 | */ 84 | @Tag(1) 85 | @DisplayMetadata(label = "JDBC URL (Ex: jdbc:snowflake://.snowflakecomputing.com/?param1=value¶m2=value)") 86 | public String jdbcURL; 87 | 88 | @Tag(2) 89 | @DisplayMetadata(label = "Username") 90 | public String username; 91 | 92 | @Tag(3) 93 | @Secret 94 | @DisplayMetadata(label = "Password") 95 | public String password; 96 | 97 | @Tag(4) 98 | @DisplayMetadata(label = "Secret resource url") 99 | public String secretResourceUrl; 100 | 101 | @Tag(5) 102 | @DisplayMetadata(label = "Record fetch size") 103 | @NotMetadataImpacting 104 | public int fetchSize = 2000; 105 | 106 | //Leave this as JsonIgnore to allow for migration of old data sources 107 | @Tag(6) 108 | @NotMetadataImpacting 109 | @DisplayMetadata(label = "Grant External Query access (External Query allows creation of VDS from a Snowflake query. Learn more here: https://docs.dremio.com/data-sources/external-queries.html#enabling-external-queries)") 110 | @JsonIgnore 111 | public boolean enableExternalQuery = false; 112 | 113 | @Tag(7) 114 | @DisplayMetadata(label = "Maximum idle connections") 115 | @NotMetadataImpacting 116 | public int maxIdleConns = 8; 117 | 118 | @Tag(8) 119 | @DisplayMetadata(label = "Connection idle time (s)") 120 | @NotMetadataImpacting 121 | public int idleTimeSec = 60; 122 | 123 | 124 | @VisibleForTesting 125 | public String toJdbcConnectionString() { 126 | checkNotNull(this.jdbcURL, "JDBC URL is required"); 127 | return jdbcURL; 128 | } 129 | 130 | @Override 131 | @VisibleForTesting 132 | public JdbcPluginConfig buildPluginConfig( 133 | JdbcPluginConfig.Builder configBuilder, 134 | CredentialsService credentialsService, 135 | OptionManager optionManager 136 | ) { 137 | logger.info("Connecting to Snowflake"); 138 | return configBuilder.withDialect(getDialect()) 139 | .withFetchSize(fetchSize) 140 | .withDatasourceFactory(() -> newDataSource(credentialsService)) 141 | .clearHiddenSchemas() 142 | .addHiddenSchema("SYSTEM") 143 | //.withAllowExternalQuery(enableExternalQuery) 144 | .build(); 145 | } 146 | 147 | private CloseableDataSource newDataSource(CredentialsService credentialsService) throws SQLException { 148 | 149 | PasswordCredentials credsFromCredentialsService = null; 150 | if (!Strings.isNullOrEmpty(this.secretResourceUrl)) { 151 | try { 152 | URI secretURI = URI.create(secretResourceUrl); 153 | credsFromCredentialsService = (PasswordCredentials) credentialsService.getCredentials(secretURI); 154 | } catch (IOException e) { 155 | throw new SQLException(e.getMessage(), e); 156 | } 157 | } 158 | 159 | return DataSources.newGenericConnectionPoolDataSource(DRIVER, 160 | toJdbcConnectionString(), username, (credsFromCredentialsService != null ? credsFromCredentialsService.getPassword() : password), null, 161 | DataSources.CommitMode.DRIVER_SPECIFIED_COMMIT_MODE, maxIdleConns, idleTimeSec); 162 | } 163 | 164 | @Override 165 | public ArpDialect getDialect() { 166 | return ARP_DIALECT; 167 | } 168 | 169 | @VisibleForTesting 170 | public static ArpDialect getDialectSingleton() { 171 | return ARP_DIALECT; 172 | } 173 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dremio Snowflake Connector 2 | 3 | 4 | 5 | 6 | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/ecc264fe94074379afc080f2e1549630)](https://app.codacy.com/app/narendrans/dremio-snowflake?utm_source=github.com&utm_medium=referral&utm_content=narendrans/dremio-snowflake&utm_campaign=Badge_Grade_Dashboard) 7 | [![Build Status](https://travis-ci.org/narendrans/dremio-snowflake.svg?branch=master)](https://travis-ci.org/narendrans/dremio-snowflake) 8 | ![Last Commit](https://img.shields.io/github/last-commit/narendrans/dremio-snowflake) 9 | 10 | ![Latest Release](https://img.shields.io/github/v/release/narendrans/dremio-snowflake) 11 | ![License](https://img.shields.io/badge/license-Apache%202-blue) 12 | ![Platform](https://img.shields.io/badge/platform-linux%20%7C%20macos%20%7C%20windows-blue) 13 | 14 | ### 17.0.0 Release 15 | 16 | If you are running Dremio 17.0.0+ release please download the latest version of the plugin here: https://github.com/narendrans/dremio-snowflake/releases Older versions compiled against 16.x versions of Dremio and below are NOT compatible with this. 17 | 18 | 19 | ### Contents 20 | 21 | 22 | * [Overview](#overview) 23 | * [Use Cases](#use-cases) 24 | * [Features](#features) 25 | * [Demo](#demo) 26 | * [Downloading a Release](#downloading-a-release) 27 | * [Usage](#usage) 28 | * [Development](#development) 29 | * [Building and Installation](#building-and-installation) 30 | * [Building a Docker image](#building-a-docker-image) 31 | * [Debugging](#debugging) 32 | * [Contribution](#contribution) 33 | * [Submitting an issue](#submitting-an-issue) 34 | * [Pull Requests](#pull-requests) 35 | * [Troubleshooting](#troubleshooting) 36 | 37 | 38 | Overview 39 | ----------- 40 | 41 | This is a community based Snowflake Dremio connector made using the ARP framework. Check [Dremio Hub](https://github.com/dremio-hub) for more examples and [ARP Docs](https://github.com/dremio-hub/dremio-sqllite-connector#arp-file-format) for documentation. 42 | 43 | What is Dremio? 44 | ----------- 45 | 46 | Dremio delivers lightning fast query speed and a self-service semantic layer operating directly against your data lake storage and other sources. No moving data to proprietary data warehouses or creating cubes, aggregation tables and BI extracts. Just flexibility and control for Data Architects, and self-service for Data Consumers. 47 | 48 | Use Cases 49 | ----------- 50 | 51 | * [Join data](https://www.dremio.com/tutorials/combining-data-from-multiple-datasets/) from Snowflake with other sources (On prem/Cloud) 52 | * Interactive SQL performance with [Data Reflections](https://www.dremio.com/tutorials/getting-started-with-data-reflections/) 53 | * Offload Snowflake tables using [CTAS](https://www.dremio.com/tutorials/high-performance-parallel-exports/) to your cheap data lake storage - HDFS, S3, ADLS 54 | * Or use [COPY INTO](https://docs.snowflake.net/manuals/sql-reference/sql/copy-into-location.html) to export data from Snowflake into S3/ADLS and query them directly using Dremio or [create external reflections](https://docs.dremio.com/acceleration/creating-reflections.html#external-reflections) on top of them. 55 | * [Curate Datasets](https://www.dremio.com/tutorials/data-curation-with-dremio/) easily through the self-service platform 56 | 57 | Features 58 | ----------- 59 | 60 | * Complete datatype support 61 | * Pushdown of over 50+ functions 62 | * Verified push downs of all TPCH queries 63 | 64 | 65 | Demo 66 | ----------- 67 | 68 | ![Snowflake demo](snowflake.gif) 69 | 70 | Downloading a Release 71 | ----------- 72 | 73 | * To download a release, [click here](https://github.com/narendrans/dremio-snowflake/releases) 74 | 75 | Usage 76 | ----------- 77 | 78 | ### Creating a new Snowflake Source 79 | 80 | ### Required Parameters 81 | 82 | * JDBC URL 83 | * Ex: `jdbc:snowflake://.snowflakecomputing.com/?param1=value¶m2=value`. [More details](https://docs.snowflake.net/manuals/user-guide/jdbc-configure.html). 84 | * Username, Password 85 | * The username and password with which you want to connect to Snowflake. Password is not needed if you want to use a PEM file. In that case you can use a JDBC string like below (The pem must exist on all the nodes) 86 | `jdbc:snowflake://account.us-east-1.snowflakecomputing.com?warehouse=compute_wh&private_key_file=/Users/naren/Desktop/rsa_key.pem` 87 | 88 | ## Development 89 | 90 | Building and Installation 91 | ----------- 92 | 93 | 0. Change the pom's dremio.version to suit your Dremio's version. `17.0.0-202107060524010627-31b5222b` 94 | 1. In root directory with the pom.xml file run `mvn clean install -DskipTests`. If you want to run the tests, add the JDBC jar to your local maven repo along with environment variables that are required. Check the basic test example for more details. 95 | 2. Take the resulting .jar file in the target folder and put it in the \jars folder in Dremio 96 | 3. Download the Snowflake JDBC driver from (https://mvnrepository.com/artifact/net.snowflake/snowflake-jdbc) and put in in the \jars\3rdparty folder 97 | 4. Restart Dremio 98 | 99 | Debugging 100 | ----------- 101 | To debug pushdowns for queries set the following line in `logback.xml` 102 | 103 | ``` 104 | 105 | 106 | 107 | ``` 108 | 109 | You can then notice lines like below in server.log file after which you can revist the YAML file to add pushdowns based on [Snowflake SQL Reference](https://docs.snowflake.net/manuals/sql-reference-commands.html): 110 | 111 | ```diff 112 | - 2019-07-11 18:56:24,001 [22d879a7-ce3d-f2ca-f380-005a88865700/0:foreman-planning] DEBUG c.d.e.store.jdbc.dialect.arp.ArpYaml - Operator / not supported. Aborting pushdown. 113 | ``` 114 | 115 | You can also take a look at the planning tab/visualized plan of the profile to determine if everything is pushed down or not. 116 | 117 | Contribution 118 | ------------ 119 | 120 | ### Submitting an issue 121 | 122 | * Go to the issue submission page: https://github.com/narendrans/dremio-snowflake/issues/new/choose. Please select an appropriate category and provide as much details as you can. 123 | 124 | ### Pull Requests 125 | 126 | PRs are welcome. When submitting a PR make sure of the following: 127 | 128 | * Try to follow Google's Java style coding when modifying/creating Java related content. 129 | * Use a YAML linter to check the syntactic correctness of YAML file 130 | * Make sure the build passes 131 | * Run basic queries at least to ensure things are working properly 132 | 133 | Troubleshooting 134 | ------------ 135 | 136 | ### Snowflake unable to create the cache directory 137 | 138 | If you see the following trace in dremio: 139 | 140 | ``` 141 | Caused by: java.lang.RuntimeException: Failed to locate or create the cache directory: /home/dremio/.cache/snowflake 142 | at net.snowflake.client.core.FileCacheManager.build(FileCacheManager.java:159) ~[snowflake-jdbc-3.8.7.jar:3.8.7] 143 | at net.snowflake.client.core.SFTrustManager.(SFTrustManager.java:197) ~[snowflake-jdbc-3.8.7.jar:3.8.7] 144 | ... 21 common frames omitted 145 | ``` 146 | You should then set the File cache environment variables documented [here](https://docs.snowflake.net/manuals/user-guide/jdbc-configure.html#file-caches) 147 | 148 | ``` 149 | export SF_TEMPORARY_CREDENTIAL_CACHE_DIR= 150 | export SF_OCSP_RESPONSE_CACHE_DIR= 151 | ``` 152 | 153 | To set them as JAVA properties, add them to the [conf/dremio-env file](https://docs.dremio.com/advanced-administration/dremio-env.html) 154 | 155 | `DREMIO_JAVA_SERVER_EXTRA_OPTS='-Dnet.snowflake.jdbc.temporaryCredentialCacheDir=/tmp -Dnet.snowflake.jdbc.ocspResponseCacheDir=/tmp'` 156 | -------------------------------------------------------------------------------- /src/test/java/com/dremio/snowflake/SnowflakeTest.java: -------------------------------------------------------------------------------- 1 | package com.dremio.snowflake; 2 | 3 | 4 | import static org.junit.Assert.assertEquals; 5 | 6 | import com.fasterxml.jackson.databind.ObjectMapper; 7 | import java.io.File; 8 | import java.io.IOException; 9 | import java.nio.charset.StandardCharsets; 10 | import java.sql.Connection; 11 | import java.sql.DriverManager; 12 | import java.sql.ResultSet; 13 | import java.sql.SQLException; 14 | import java.sql.Statement; 15 | import java.util.Properties; 16 | import java.util.TimeZone; 17 | import org.apache.commons.io.FileUtils; 18 | import org.apache.http.client.methods.CloseableHttpResponse; 19 | import org.apache.http.client.methods.HttpDelete; 20 | import org.apache.http.client.methods.HttpPost; 21 | import org.apache.http.client.methods.HttpPut; 22 | import org.apache.http.entity.StringEntity; 23 | import org.apache.http.impl.client.CloseableHttpClient; 24 | import org.apache.http.impl.client.HttpClients; 25 | import org.apache.http.util.EntityUtils; 26 | import org.apache.log4j.Logger; 27 | import org.junit.AfterClass; 28 | import org.junit.BeforeClass; 29 | import org.junit.FixMethodOrder; 30 | import org.junit.Test; 31 | import org.junit.runners.MethodSorters; 32 | 33 | @FixMethodOrder(MethodSorters.NAME_ASCENDING) 34 | public class SnowflakeTest { 35 | 36 | private static Logger log = Logger.getLogger(SnowflakeTest.class); 37 | 38 | 39 | /* Snowflake connection settings */ 40 | 41 | private static String authToken = "_dremio"; 42 | 43 | private static final String snowflakeJdbcURL = System.getenv("SNOWFLAKE_JDBC_URL"); 44 | private static final String snowflakeUser = System.getenv("SNOWFLAKE_USER"); 45 | private static final String snowflakePassword = System.getenv("SNOWFLAKE_PASSWORD"); 46 | 47 | @BeforeClass 48 | public static void setup() throws IOException, SQLException { 49 | 50 | log.info("Dremio: Get authentication token"); 51 | CloseableHttpClient client = HttpClients.createDefault(); 52 | HttpPost httpPost = new HttpPost("http://localhost:9047/apiv2/login"); 53 | 54 | String json = "{\"userName\": \"dremio\",\"password\": \"dremio123\"}"; 55 | 56 | httpPost.setEntity(new StringEntity(json)); 57 | httpPost.setHeader("Content-type", "application/json"); 58 | 59 | CloseableHttpResponse response = client.execute(httpPost); 60 | 61 | authToken = authToken + new ObjectMapper() 62 | .readTree(EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8)). 63 | findValue("token").asText(); 64 | 65 | client.close(); 66 | 67 | // Create test table and insert sample data 68 | 69 | log.info("Snowflake: Create test table"); 70 | Properties properties = new Properties(); 71 | properties.put("user", snowflakeUser); 72 | properties.put("password", snowflakePassword); 73 | 74 | Statement statement = DriverManager.getConnection(snowflakeJdbcURL, properties) 75 | .createStatement(); 76 | 77 | String[] sqls = FileUtils 78 | .readFileToString(new File(new File("src/test/resources/DDL.sql").getPath()), 79 | StandardCharsets.UTF_8).split(";"); 80 | 81 | // Snowflake doesn't support executing multiple SQLs in a single call 82 | statement.executeUpdate(sqls[0]); 83 | statement.executeUpdate(sqls[1]); 84 | 85 | log.info("Dremio: Create Snowflake datasource"); 86 | CloseableHttpClient createSourceClient = HttpClients.createDefault(); 87 | HttpPut httpPut = new HttpPut("http://localhost:9047/apiv2/source/snowflake"); 88 | 89 | String jsonPayload = String.format("{\n" 90 | + " \"name\": \"snowflake\",\n" 91 | + " \"config\": {\n" 92 | + " \"jdbcURL\": \"%s\",\n" 93 | + " \"username\": \"%s\",\n" 94 | + " \"password\": \"%s\",\n" 95 | + " \"fetchSize\": 2000\n" 96 | + " },\n" 97 | + " \"accelerationRefreshPeriod\": 3600000,\n" 98 | + " \"accelerationGracePeriod\": 10800000,\n" 99 | + " \"metadataPolicy\": {\n" 100 | + " \"deleteUnavailableDatasets\": true,\n" 101 | + " \"namesRefreshMillis\": 3600000,\n" 102 | + " \"datasetDefinitionRefreshAfterMillis\": 3600000,\n" 103 | + " \"datasetDefinitionExpireAfterMillis\": 10800000,\n" 104 | + " \"authTTLMillis\": 86400000,\n" 105 | + " \"updateMode\": \"PREFETCH_QUERIED\"\n" 106 | + " },\n" 107 | + " \"accessControlList\": {\n" 108 | + " \"userControls\": [],\n" 109 | + " \"groupControls\": []\n" 110 | + " },\n" 111 | + " \"type\": \"SNOWFLAKE\"\n" 112 | + "}", snowflakeJdbcURL, snowflakeUser, snowflakePassword); 113 | 114 | httpPut.setEntity(new StringEntity(jsonPayload)); 115 | httpPut.setHeader("Content-type", "application/json"); 116 | httpPut.setHeader("Authorization", authToken); 117 | 118 | assertEquals(200, createSourceClient.execute(httpPut).getStatusLine().getStatusCode()); 119 | 120 | client.close(); 121 | 122 | } 123 | 124 | 125 | @Test 126 | public void queryTest() throws IOException, SQLException { 127 | log.info("Dremio: SELECT * FROM all_types"); 128 | 129 | TimeZone.setDefault(TimeZone.getTimeZone("Etc/UTC")); 130 | 131 | // Get resultset from Dremio 132 | Connection dremioConnection = DriverManager 133 | .getConnection("jdbc:dremio:direct=localhost;user=dremio;password=dremio123"); 134 | 135 | Statement dremioStatement = dremioConnection.createStatement(); 136 | 137 | ResultSet dremioRs = dremioStatement 138 | .executeQuery("SELECT * FROM snowflake.\"DEMO_DB\".\"PUBLIC\".all_types"); 139 | dremioRs.next(); 140 | 141 | // Get resultset from Snowflake 142 | Properties properties = new Properties(); 143 | properties.put("user", snowflakeUser); 144 | properties.put("password", snowflakePassword); 145 | Connection snowflakeConnection = DriverManager 146 | .getConnection(snowflakeJdbcURL, properties); 147 | 148 | Statement snowflakeStatement = snowflakeConnection.createStatement(); 149 | 150 | ResultSet snowflakeRs = snowflakeStatement 151 | .executeQuery("SELECT * FROM \"DEMO_DB\".\"PUBLIC\".\"all_types\""); 152 | snowflakeRs.next(); 153 | 154 | 155 | // Compare 156 | 157 | assertEquals(dremioRs.getBigDecimal("A"), snowflakeRs.getBigDecimal("A")); 158 | assertEquals(dremioRs.getInt("B"), snowflakeRs.getInt("B")); 159 | assertEquals(dremioRs.getInt("C"), snowflakeRs.getInt("C")); 160 | assertEquals(dremioRs.getInt("D"), snowflakeRs.getInt("D")); 161 | assertEquals(dremioRs.getInt("E"), snowflakeRs.getInt("E")); 162 | assertEquals(dremioRs.getInt("F"), snowflakeRs.getInt("F")); 163 | 164 | assertEquals(dremioRs.getDouble("G"), snowflakeRs.getDouble("G"),0.1); 165 | assertEquals(dremioRs.getDouble("H"), snowflakeRs.getDouble("H"),0.1); 166 | assertEquals(dremioRs.getDouble("I"), snowflakeRs.getDouble("I"),0.1); 167 | assertEquals(dremioRs.getDouble("J"), snowflakeRs.getDouble("J"),0.1); 168 | assertEquals(dremioRs.getDouble("K"), snowflakeRs.getDouble("K"),0.1); 169 | assertEquals(dremioRs.getDouble("L"), snowflakeRs.getDouble("L"),0.1); 170 | 171 | assertEquals(dremioRs.getString("M"), snowflakeRs.getString("M")); 172 | assertEquals(dremioRs.getString("N"), snowflakeRs.getString("N")); 173 | assertEquals(dremioRs.getString("O"), snowflakeRs.getString("O")); 174 | assertEquals(dremioRs.getString("P"), snowflakeRs.getString("P")); 175 | 176 | assertEquals(new String(dremioRs.getBytes("Q")), new String(snowflakeRs.getBytes("Q"))); 177 | assertEquals(new String(dremioRs.getBytes("R")), new String(snowflakeRs.getBytes("R"))); 178 | 179 | assertEquals(dremioRs.getTimestamp("S"), snowflakeRs.getTimestamp("S")); 180 | //assertEquals(dremioRs.getTime("T"), snowflakeRs.getTime("T")); 181 | assertEquals(dremioRs.getTimestamp("U"), snowflakeRs.getTimestamp("U")); 182 | 183 | 184 | dremioStatement.close(); 185 | snowflakeStatement.close(); 186 | 187 | } 188 | 189 | @AfterClass 190 | public static void cleanUp() throws IOException, SQLException, InterruptedException { 191 | 192 | log.info("Dremio: Removing Snowflake data source in 5 seconds"); 193 | 194 | CloseableHttpClient client = HttpClients.createDefault(); 195 | HttpDelete httpDelete = new HttpDelete( 196 | "http://localhost:9047/apiv2/source/snowflake?version=1"); 197 | 198 | httpDelete.setHeader("Content-type", "application/json"); 199 | httpDelete.setHeader("Authorization", authToken); 200 | 201 | client.execute(httpDelete); 202 | 203 | client.close(); 204 | 205 | log.info("Snowflake: Remove test table"); 206 | Properties properties = new Properties(); 207 | properties.put("user", snowflakeUser); 208 | properties.put("password", snowflakePassword); 209 | 210 | Statement statement = DriverManager.getConnection(snowflakeJdbcURL, properties) 211 | .createStatement(); 212 | statement.executeUpdate("DROP TABLE \"DEMO_DB\".\"PUBLIC\".\"all_types\""); 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /src/main/resources/arp/implementation/snowflake-arp.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2017-2019 Dremio Corporation 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | metadata: 18 | # Manually Configured Metadata Section. 19 | name: SNOWFLAKE 20 | apiname: snowflake 21 | spec_version: '2' 22 | 23 | syntax: 24 | # Manually Configured Syntax Section. 25 | identifier_quote: '"' #https://docs.snowflake.net/manuals/sql-reference/identifiers-syntax.html#double-quoted-identifiers 26 | identifier_length_limit: 256 #https://docs.snowflake.net/manuals/sql-reference/identifiers.html#object-identifiers 27 | allows_boolean_literal: false 28 | map_boolean_literal_to_bit: false 29 | supports_catalogs: true 30 | supports_schemas: true 31 | 32 | # https://docs.snowflake.net/manuals/sql-reference/intro-summary-data-types.html 33 | data_types: 34 | mappings: 35 | #------------Boolean types--------------# 36 | - source: 37 | name: "BOOLEAN" 38 | dremio: 39 | name: "boolean" 40 | 41 | #------------Numeric types--------------# 42 | - source: 43 | name: "NUMERIC" 44 | max_precision: 38 45 | max_scale: 37 46 | required_cast_args: "precision_scale" 47 | dremio: 48 | name: "DECIMAL" 49 | 50 | - source: 51 | name: "NUMBER" 52 | max_precision: 38 53 | max_scale: 37 54 | dremio: 55 | name: "DECIMAL" 56 | 57 | - source: 58 | name: "DECIMAL" 59 | max_precision: 38 60 | max_scale: 37 61 | required_cast_args: "precision_scale" 62 | dremio: 63 | name: "DECIMAL" 64 | 65 | - source: 66 | name: "INT" 67 | dremio: 68 | name: "integer" 69 | - source: 70 | name: "INTEGER" 71 | dremio: 72 | name: "integer" 73 | - source: 74 | name: "SMALLINT" 75 | dremio: 76 | name: "integer" 77 | - source: 78 | name: "BIGINT" 79 | dremio: 80 | name: "bigint" 81 | 82 | - source: 83 | name: "FLOAT" 84 | dremio: 85 | name: "double" 86 | - source: 87 | name: "FLOAT4" 88 | dremio: 89 | name: "double" 90 | - source: 91 | name: "FLOAT8" 92 | dremio: 93 | name: "double" 94 | - source: 95 | name: "DOUBLE" 96 | dremio: 97 | name: "double" 98 | - source: 99 | name: "DOUBLE PRECISION" 100 | dremio: 101 | name: "double" 102 | 103 | #------------String types--------------# 104 | - source: 105 | name: "VARCHAR" 106 | max_precision: 16777216 107 | literal_length_limit: 16777216 108 | required_cast_args: "precision" 109 | dremio: 110 | name: "varchar" 111 | - source: 112 | name: "CHAR" 113 | max_precision: 1 114 | literal_length_limit: 1 115 | dremio: 116 | name: "varchar" 117 | - source: 118 | name: "CHARACTER" 119 | max_precision: 1 120 | literal_length_limit: 1 121 | dremio: 122 | name: "varchar" 123 | - source: 124 | name: "STRING" 125 | dremio: 126 | name: "varchar" 127 | 128 | #------------Binary--------------# 129 | # https://docs.snowflake.net/manuals/sql-reference/data-types-text.html#binary 130 | - source: 131 | name: "binary" 132 | max_precision: 8388608 133 | literal_length_limit: 8388608 134 | required_cast_args: "precision" 135 | dremio: 136 | name: "varbinary" 137 | 138 | #------------Date types--------------# 139 | - source: 140 | name: "DATE" 141 | dremio: 142 | name: "date" 143 | - source: 144 | name: "TIME" 145 | dremio: 146 | name: "time" 147 | - source: 148 | name: "TIMESTAMP" 149 | dremio: 150 | name: "timestamp" 151 | - source: 152 | name: "TIMESTAMP_LTZ" 153 | dremio: 154 | name: "timestamp" 155 | - source: 156 | name: "TIMESTAMP_NTZ" 157 | dremio: 158 | name: "timestamp" 159 | - source: 160 | name: "TIMESTAMP_TZ" 161 | dremio: 162 | name: "timestamp" 163 | - source: 164 | name: "TIMESTAMPLTZ" 165 | dremio: 166 | name: "timestamp" 167 | - source: 168 | name: "TIMESTAMPNTZ" 169 | dremio: 170 | name: "timestamp" 171 | - source: 172 | name: "TIMESTAMPTZ" 173 | dremio: 174 | name: "timestamp" 175 | #------------ Snowflake's complex VARIANT type (JSON) is mapped to Dremio's VARCHAR. -------------# 176 | #------------ You can use convert_from(, 'JSON') in Dremio to treat it as a JSON -------------# 177 | - source: 178 | name: "VARIANT" 179 | dremio: 180 | name: "VARCHAR" 181 | 182 | relational_algebra: 183 | aggregation: 184 | enable: true 185 | group_by_ordinal: false 186 | distinct: true 187 | count_functions: 188 | count_star: 189 | enable: true 190 | count: 191 | enable: true 192 | count_distinct: 193 | enable: true 194 | # https://docs.snowflake.net/manuals/sql-reference-functions.html 195 | 196 | functions: 197 | - names: 198 | - "avg" 199 | signatures: 200 | - args: 201 | - "double" 202 | return: "double" 203 | - args: 204 | - "decimal" 205 | return: "decimal" 206 | - args: 207 | - "integer" 208 | return: "double" 209 | - names: 210 | - "max" 211 | - "min" 212 | signatures: 213 | - args: 214 | - "integer" 215 | return: "integer" 216 | - args: 217 | - "double" 218 | return: "double" 219 | - args: 220 | - "decimal" 221 | return: "decimal" 222 | - args: 223 | - "varchar" 224 | return: "varchar" 225 | - names: 226 | - "sum" 227 | signatures: 228 | - args: 229 | - "double" 230 | return: "double" 231 | - args: 232 | - "decimal" 233 | return: "decimal" 234 | - args: 235 | - "integer" 236 | return: "bigint" 237 | - names: 238 | - "stddev" 239 | - "stddev_pop" 240 | - "stddev_samp" 241 | - "var_pop" 242 | - "var_samp" 243 | signatures: 244 | - args: 245 | - "bigint" 246 | return: "double" 247 | - args: 248 | - "double" 249 | return: "double" 250 | - args: 251 | - "float" 252 | return: "double" 253 | - args: 254 | - "integer" 255 | return: "double" 256 | - args: 257 | - "decimal" 258 | return: "decimal" 259 | except: 260 | enable: false 261 | project: 262 | enable: true 263 | join: 264 | enable: true 265 | cross: 266 | enable: true 267 | rewrite: "{0}, {1}" 268 | inner: 269 | enable: true 270 | inequality: true 271 | left: 272 | enable: true 273 | inequality: true 274 | right: 275 | enable: true 276 | inequality: true 277 | full: 278 | enable: true 279 | inequality: true 280 | sort: 281 | enable: true 282 | order_by: 283 | enable: true 284 | default_nulls_ordering: high 285 | fetch_offset: # https://docs.snowflake.net/manuals/sql-reference/constructs/limit.html#limit-fetch 286 | offset_fetch: 287 | enable: true 288 | format: 'LIMIT {1} OFFSET {0}' 289 | offset_only: 290 | enable: false 291 | fetch_only: 292 | enable: true 293 | format: 'LIMIT {0}' 294 | # https://docs.snowflake.net/manuals/sql-reference/operators-query.html#union-all 295 | union: 296 | enable: true 297 | union_all: 298 | enable: true 299 | values: 300 | enable: false 301 | method: values 302 | 303 | # Describe the set of function signatures that are internally supported. 304 | expressions: 305 | subqueries: 306 | enable: true 307 | correlated: true 308 | scalar: true 309 | in_clause: true 310 | supports_case: true 311 | supports_over: true 312 | datetime_formats: #https://docs.snowflake.net/manuals/sql-reference/data-types-datetime.html#date-and-time-formats 313 | meridian: 314 | enable: true 315 | format: "AM" 316 | day_of_week: 317 | enable: true 318 | format: "D" 319 | day_name_abbreviated: 320 | enable: true 321 | format: "DY" 322 | day_name: 323 | enable: true 324 | format: "Day" 325 | year_4: 326 | enable: true 327 | format: "YYYY" 328 | year_2: 329 | enable: true 330 | format: "YY" 331 | month: 332 | enable: true 333 | format: "MM" 334 | month_name_abbreviated: 335 | enable: true 336 | format: "Mon" 337 | month_name: 338 | enable: true 339 | format: "Month" 340 | day_of_month: 341 | enable: true 342 | format: "DD" 343 | hour_12: 344 | enable: true 345 | format: "HH12" 346 | hour_24: 347 | enable: true 348 | format: "HH24" 349 | minute: 350 | enable: true 351 | format: "MI" 352 | second: 353 | enable: true 354 | format: "SS" 355 | timezone_abbreviation: 356 | enable: true 357 | format: "TZ" 358 | operators: 359 | - names: 360 | - "cast" 361 | signatures: 362 | - args: 363 | - "varchar" 364 | return: "integer" 365 | rewrite: "CAST(TRUNC(CAST({0} AS DECIMAL), 0) AS INTEGER)" 366 | - args: 367 | - "varchar" 368 | return: "bigint" 369 | rewrite: "CAST(TRUNC(CAST({0} AS DECIMAL), 0) AS BIGINT)" 370 | - names: 371 | - "trim" #https://docs.snowflake.net/manuals/sql-reference/functions/trim.html 372 | signatures: 373 | - args: 374 | - "varchar" 375 | return: "varchar" 376 | - names: #https://docs.snowflake.net/manuals/sql-reference/functions/ltrim.html 377 | - "ltrim" 378 | signatures: 379 | - args: 380 | - "varchar" 381 | return: "varchar" 382 | - names: #https://docs.snowflake.net/manuals/sql-reference/functions/rtrim.html 383 | - "rtrim" 384 | signatures: 385 | - args: 386 | - "varchar" 387 | return: "varchar" 388 | - names: #https://docs.snowflake.net/manuals/sql-reference/functions/sign.html 389 | - "sign" 390 | signatures: 391 | - args: 392 | - "bigint" 393 | return: "integer" 394 | - args: 395 | - "double" 396 | return: "integer" 397 | - args: 398 | - "decimal" 399 | return: "integer" 400 | - args: 401 | - "float" 402 | return: "integer" 403 | - args: 404 | - "integer" 405 | return: "integer" 406 | - names: 407 | - "floor" #https://docs.snowflake.net/manuals/sql-reference/functions/floor.html. 408 | signatures: 409 | - args: 410 | - "bigint" 411 | return: "bigint" 412 | - args: 413 | - "double" 414 | return: "double" 415 | - args: 416 | - "decimal" 417 | return: "decimal" 418 | - args: 419 | - "float" 420 | return: "float" 421 | - args: 422 | - "integer" 423 | return: "integer" 424 | - names: #https://docs.snowflake.net/manuals/sql-reference/functions/position.html 425 | - "position" 426 | - "locate" 427 | signatures: 428 | - args: 429 | - "varchar" 430 | - "varchar" 431 | return: "integer" 432 | rewrite: "POSITION({0}, {1})" 433 | - args: 434 | - "varchar" 435 | - "varchar" 436 | - "integer" 437 | return: "integer" 438 | rewrite: "POSITION({0}, {1}, {2})" 439 | - names: 440 | - "pi" 441 | signatures: 442 | - args: [] 443 | return: "double" 444 | - names: 445 | - "truncate" 446 | signatures: 447 | - args: 448 | - "double" 449 | - "integer" 450 | return: "double" 451 | rewrite: "TRUNC({0}, {1})" 452 | - args: 453 | - "decimal" 454 | - "integer" 455 | return: "decimal" 456 | rewrite: "TRUNC({0}, {1})" 457 | - args: 458 | - "float" 459 | - "integer" 460 | return: "float" 461 | rewrite: "TRUNC({0}, {1})" 462 | - args: 463 | - "bigint" 464 | - "integer" 465 | return: "bigint" 466 | rewrite: "TRUNC({0}, {1})" 467 | - args: 468 | - "integer" 469 | - "integer" 470 | return: "integer" 471 | rewrite: "TRUNC({0}, {1})" 472 | - args: 473 | - "double" 474 | return: "double" 475 | rewrite: "TRUNC({0})" 476 | - args: 477 | - "decimal" 478 | return: "decimal" 479 | rewrite: "TRUNC({0})" 480 | - args: 481 | - "float" 482 | return: "float" 483 | rewrite: "TRUNC({0})" 484 | - args: 485 | - "integer" 486 | return: "integer" 487 | rewrite: "TRUNC({0})" 488 | - args: 489 | - "bigint" 490 | return: "bigint" 491 | rewrite: "TRUNC({0})" 492 | - names: 493 | - "reverse" 494 | signatures: 495 | - args: 496 | - "varchar" 497 | return: "varchar" 498 | - names: 499 | - "rpad" #https://docs.snowflake.net/manuals/sql-reference/functions/rpad.html 500 | signatures: 501 | - args: 502 | - "varchar" 503 | - "integer" 504 | - "varchar" 505 | return: "varchar" 506 | - args: 507 | - "varchar" 508 | - "bigint" 509 | - "varchar" 510 | return: "varchar" 511 | - names: 512 | - "lpad" #https://docs.snowflake.net/manuals/sql-reference/functions/lpad.html 513 | signatures: 514 | - args: 515 | - "varchar" 516 | - "integer" 517 | - "varchar" 518 | return: "varchar" 519 | - args: 520 | - "varchar" 521 | - "bigint" 522 | - "varchar" 523 | return: "varchar" 524 | - names: 525 | - "length" #https://docs.snowflake.net/manuals/sql-reference/functions/length.html 526 | signatures: 527 | - args: 528 | - "varchar" 529 | return: "integer" 530 | - names: 531 | - "lower" #https://docs.snowflake.net/manuals/sql-reference/functions/lower.html 532 | signatures: 533 | - args: 534 | - "varchar" 535 | return: "varchar" 536 | - names: 537 | - "regexp_like" #https://docs.snowflake.net/manuals/sql-reference/functions/regexp_like.html 538 | signatures: 539 | - args: 540 | - "varchar" 541 | - "varchar" 542 | return: "boolean" 543 | - names: 544 | - "replace" #https://docs.snowflake.net/manuals/sql-reference/functions/replace.html 545 | signatures: 546 | - args: 547 | - "varchar" 548 | - "varchar" 549 | - "varchar" 550 | return: "varchar" 551 | - names: 552 | - "upper" #https://docs.snowflake.net/manuals/sql-reference/functions/upper.html 553 | signatures: 554 | - args: 555 | - "varchar" 556 | return: "varchar" 557 | - names: 558 | - "timestampdiff_day" #https://docs.snowflake.net/manuals/sql-reference/functions/timestampdiff.html 559 | signatures: 560 | - args: 561 | - "timestamp" 562 | - "timestamp" 563 | return: "integer" 564 | - args: 565 | - "time" 566 | - "time" 567 | return: "integer" 568 | - args: 569 | - "date" 570 | - "date" 571 | return: "integer" 572 | - args: 573 | - "timestamp" 574 | - "date" 575 | return: "integer" 576 | - args: 577 | - "timestamp" 578 | - "time" 579 | return: "integer" 580 | - args: 581 | - "time" 582 | - "timestamp" 583 | return: "integer" 584 | - args: 585 | - "time" 586 | - "date" 587 | return: "integer" 588 | - args: 589 | - "date" 590 | - "time" 591 | return: "integer" 592 | - args: 593 | - "date" 594 | - "timestamp" 595 | return: "integer" 596 | - names: 597 | - "timestampdiff_hour" #https://docs.snowflake.net/manuals/sql-reference/functions/timestampdiff.html 598 | signatures: 599 | - args: 600 | - "timestamp" 601 | - "timestamp" 602 | return: "integer" 603 | - args: 604 | - "time" 605 | - "time" 606 | return: "integer" 607 | - args: 608 | - "date" 609 | - "date" 610 | return: "integer" 611 | - args: 612 | - "timestamp" 613 | - "date" 614 | return: "integer" 615 | - args: 616 | - "timestamp" 617 | - "time" 618 | return: "integer" 619 | - args: 620 | - "time" 621 | - "timestamp" 622 | return: "integer" 623 | - args: 624 | - "time" 625 | - "date" 626 | return: "integer" 627 | - args: 628 | - "date" 629 | - "time" 630 | return: "integer" 631 | - args: 632 | - "date" 633 | - "timestamp" 634 | return: "integer" 635 | - names: 636 | - "timestampdiff_minute" #https://docs.snowflake.net/manuals/sql-reference/functions/timestampdiff.html 637 | signatures: 638 | - args: 639 | - "timestamp" 640 | - "timestamp" 641 | return: "integer" 642 | - args: 643 | - "time" 644 | - "time" 645 | return: "integer" 646 | - args: 647 | - "date" 648 | - "date" 649 | return: "integer" 650 | - args: 651 | - "timestamp" 652 | - "date" 653 | return: "integer" 654 | - args: 655 | - "timestamp" 656 | - "time" 657 | return: "integer" 658 | - args: 659 | - "time" 660 | - "timestamp" 661 | return: "integer" 662 | - args: 663 | - "time" 664 | - "date" 665 | return: "integer" 666 | - args: 667 | - "date" 668 | - "time" 669 | return: "integer" 670 | - args: 671 | - "date" 672 | - "timestamp" 673 | return: "integer" 674 | - names: 675 | - "timestampdiff_month" #https://docs.snowflake.net/manuals/sql-reference/functions/timestampdiff.html 676 | signatures: 677 | - args: 678 | - "timestamp" 679 | - "timestamp" 680 | return: "integer" 681 | - args: 682 | - "time" 683 | - "time" 684 | return: "integer" 685 | - args: 686 | - "date" 687 | - "date" 688 | return: "integer" 689 | - args: 690 | - "timestamp" 691 | - "date" 692 | return: "integer" 693 | - args: 694 | - "timestamp" 695 | - "time" 696 | return: "integer" 697 | - args: 698 | - "time" 699 | - "timestamp" 700 | return: "integer" 701 | - args: 702 | - "time" 703 | - "date" 704 | return: "integer" 705 | - args: 706 | - "date" 707 | - "time" 708 | return: "integer" 709 | - args: 710 | - "date" 711 | - "timestamp" 712 | return: "integer" 713 | - names: 714 | - "timestampdiff_second" #https://docs.snowflake.net/manuals/sql-reference/functions/timestampdiff.html 715 | signatures: 716 | - args: 717 | - "timestamp" 718 | - "timestamp" 719 | return: "integer" 720 | - args: 721 | - "time" 722 | - "time" 723 | return: "integer" 724 | - args: 725 | - "date" 726 | - "date" 727 | return: "integer" 728 | - args: 729 | - "timestamp" 730 | - "date" 731 | return: "integer" 732 | - args: 733 | - "timestamp" 734 | - "time" 735 | return: "integer" 736 | - args: 737 | - "time" 738 | - "timestamp" 739 | return: "integer" 740 | - args: 741 | - "time" 742 | - "date" 743 | return: "integer" 744 | - args: 745 | - "date" 746 | - "time" 747 | return: "integer" 748 | - args: 749 | - "date" 750 | - "timestamp" 751 | return: "integer" 752 | - names: 753 | - "timestampdiff_week" # https://docs.snowflake.com/en/sql-reference/functions/timestampdiff.html 754 | signatures: 755 | - args: 756 | - "timestamp" 757 | - "timestamp" 758 | return: "integer" 759 | - args: 760 | - "time" 761 | - "time" 762 | return: "integer" 763 | - args: 764 | - "date" 765 | - "date" 766 | return: "integer" 767 | - args: 768 | - "timestamp" 769 | - "date" 770 | return: "integer" 771 | - args: 772 | - "timestamp" 773 | - "time" 774 | return: "integer" 775 | - args: 776 | - "time" 777 | - "timestamp" 778 | return: "integer" 779 | - args: 780 | - "time" 781 | - "date" 782 | return: "integer" 783 | - args: 784 | - "date" 785 | - "time" 786 | return: "integer" 787 | - args: 788 | - "date" 789 | - "timestamp" 790 | return: "integer" 791 | - names: 792 | - "timestampdiff_year" #https://docs.snowflake.net/manuals/sql-reference/functions/timestampdiff.html 793 | signatures: 794 | - args: 795 | - "timestamp" 796 | - "timestamp" 797 | return: "integer" 798 | - args: 799 | - "time" 800 | - "time" 801 | return: "integer" 802 | - args: 803 | - "date" 804 | - "date" 805 | return: "integer" 806 | - args: 807 | - "timestamp" 808 | - "date" 809 | return: "integer" 810 | - args: 811 | - "timestamp" 812 | - "time" 813 | return: "integer" 814 | - args: 815 | - "time" 816 | - "timestamp" 817 | return: "integer" 818 | - args: 819 | - "time" 820 | - "date" 821 | return: "integer" 822 | - args: 823 | - "date" 824 | - "time" 825 | return: "integer" 826 | - args: 827 | - "date" 828 | - "timestamp" 829 | return: "integer" 830 | - names: #https://docs.snowflake.net/manuals/sql-reference/functions/substr.html 831 | - "substring" 832 | signatures: 833 | - args: 834 | - "varchar" 835 | - "integer" 836 | - "integer" 837 | return: "varchar" 838 | rewrite: "substring({0},{1},{2})" 839 | - args: 840 | - "varchar" 841 | - "integer" 842 | return: "varchar" 843 | rewrite: "substring({0},{1})" 844 | - names: 845 | - "substr" 846 | signatures: 847 | - args: 848 | - "varchar" 849 | - "integer" 850 | - "integer" 851 | return: "varchar" 852 | rewrite: "substring({0},{1},{2})" 853 | - args: 854 | - "varchar" 855 | - "integer" 856 | return: "varchar" 857 | rewrite: "substring({0},{1})" 858 | # Snowlake supports both EXTRACT (type from field) and YEAR/MONTH/DAY/SECOND etc.. 859 | # https://docs.snowflake.net/manuals/sql-reference/functions/date_part.html 860 | - names: 861 | - extract_year 862 | signatures: 863 | - return: bigint 864 | args: 865 | - date 866 | rewrite: "YEAR({0})" 867 | - return: bigint 868 | args: 869 | - timestamp 870 | rewrite: "YEAR({0})" 871 | - return: bigint 872 | args: 873 | - time 874 | rewrite: "YEAR({0})" 875 | - names: 876 | - extract_month 877 | signatures: 878 | - return: bigint 879 | args: 880 | - date 881 | rewrite: "MONTH({0})" 882 | - return: bigint 883 | args: 884 | - timestamp 885 | rewrite: "MONTH({0})" 886 | - return: bigint 887 | args: 888 | - time 889 | rewrite: "MONTH({0})" 890 | - names: 891 | - extract_day 892 | signatures: 893 | - return: bigint 894 | args: 895 | - date 896 | rewrite: "DAY({0})" 897 | - return: bigint 898 | args: 899 | - timestamp 900 | rewrite: "DAY({0})" 901 | - return: bigint 902 | args: 903 | - time 904 | rewrite: "DAY({0})" 905 | 906 | - names: 907 | - extract_hour 908 | signatures: 909 | - return: bigint 910 | args: 911 | - date 912 | rewrite: "HOUR({0})" 913 | - return: bigint 914 | args: 915 | - timestamp 916 | rewrite: "HOUR({0})" 917 | - return: bigint 918 | args: 919 | - time 920 | rewrite: "HOUR({0})" 921 | - names: 922 | - extract_minute 923 | signatures: 924 | - return: bigint 925 | args: 926 | - date 927 | rewrite: "MINUTE({0})" 928 | - return: bigint 929 | args: 930 | - timestamp 931 | rewrite: "MINUTE({0})" 932 | - return: bigint 933 | args: 934 | - time 935 | rewrite: "MINUTE({0})" 936 | - names: 937 | - extract_second 938 | signatures: 939 | - return: bigint 940 | args: 941 | - date 942 | rewrite: "SECOND({0})" 943 | - return: bigint 944 | args: 945 | - timestamp 946 | rewrite: "SECOND({0})" 947 | - return: bigint 948 | args: 949 | - time 950 | rewrite: "SECOND({0})" 951 | - names: 952 | - extract_dow 953 | signatures: 954 | - return: bigint 955 | args: 956 | - date 957 | rewrite: "DAYOFWEEK({0})" 958 | - return: bigint 959 | args: 960 | - timestamp 961 | rewrite: "DAYOFWEEK({0})" 962 | - return: bigint 963 | args: 964 | - time 965 | rewrite: "DAYOFWEEK({0})" 966 | 967 | - names: 968 | - extract_doy 969 | signatures: 970 | - return: bigint 971 | args: 972 | - date 973 | rewrite: "DAYOFYEAR({0})" 974 | - return: bigint 975 | args: 976 | - timestamp 977 | rewrite: "DAYOFYEAR({0})" 978 | - return: bigint 979 | args: 980 | - time 981 | rewrite: "DAYOFYEAR({0})" 982 | 983 | - names: 984 | - extract_quarter 985 | signatures: 986 | - return: bigint 987 | args: 988 | - date 989 | rewrite: "QUARTER({0})" 990 | - return: bigint 991 | args: 992 | - timestamp 993 | rewrite: "QUARTER({0})" 994 | - return: bigint 995 | args: 996 | - time 997 | rewrite: "QUARTER({0})" 998 | 999 | - names: 1000 | - extract_week 1001 | signatures: 1002 | - return: bigint 1003 | args: 1004 | - date 1005 | rewrite: "WEEK({0})" 1006 | - return: bigint 1007 | args: 1008 | - timestamp 1009 | rewrite: "WEEK({0})" 1010 | - return: bigint 1011 | args: 1012 | - time 1013 | rewrite: "WEEK({0})" 1014 | 1015 | - names: 1016 | - convert_timezone # https://docs.snowflake.com/en/sql-reference/functions/convert_timezone.html 1017 | signatures: 1018 | - return: timestamp 1019 | args: 1020 | - varchar 1021 | - timestamp 1022 | # Remove timezone from the result, otherwise Dremio will ignore it 1023 | rewrite: "TO_TIMESTAMP_NTZ(CONVERT_TIMEZONE({0}, {1}))" 1024 | - return: timestamp 1025 | args: 1026 | - varchar 1027 | - varchar 1028 | - timestamp 1029 | # Remove timezone from the result, otherwise Dremio will ignore it. Supports only timestamps without timezone. 1030 | rewrite: "TO_TIMESTAMP_NTZ(CONVERT_TIMEZONE({0}, {1}, {2}))" 1031 | 1032 | # Math functions 1033 | - names: 1034 | - "log" #https://docs.snowflake.net/manuals/sql-reference/functions/log.html 1035 | signatures: 1036 | - args: 1037 | - "double" 1038 | return: "double" 1039 | - args: 1040 | - "bigint" 1041 | return: "double" 1042 | - args: 1043 | - "integer" 1044 | return: "double" 1045 | - args: 1046 | - "decimal" 1047 | return: "decimal" 1048 | - names: 1049 | - "acos" #https://docs.snowflake.net/manuals/sql-reference/functions/acos.html 1050 | signatures: 1051 | - args: 1052 | - "double" 1053 | return: "double" 1054 | - args: 1055 | - "decimal" 1056 | return: "decimal" 1057 | - names: 1058 | - "asin" #https://docs.snowflake.net/manuals/sql-reference/functions/asin.html 1059 | signatures: 1060 | - args: 1061 | - "double" 1062 | return: "double" 1063 | - args: 1064 | - "decimal" 1065 | return: "decimal" 1066 | - names: 1067 | - "round" #https://docs.snowflake.net/manuals/sql-reference/functions/round.html 1068 | signatures: 1069 | - args: 1070 | - "integer" 1071 | return: "integer" 1072 | - args: 1073 | - "bigint" 1074 | return: "bigint" 1075 | - args: 1076 | - "double" 1077 | return: "bigint" 1078 | - args: 1079 | - "float" 1080 | return: "float" 1081 | rewrite: "bigint" 1082 | - args: 1083 | - "bigint" 1084 | - "integer" 1085 | return: "bigint" 1086 | - args: 1087 | - "bigint" 1088 | - "bigint" 1089 | return: "bigint" 1090 | - args: 1091 | - "integer" 1092 | - "integer" 1093 | return: "integer" 1094 | - args: 1095 | - "integer" 1096 | - "bigint" 1097 | return: "integer" 1098 | - args: 1099 | - "double" 1100 | - "integer" 1101 | return: "double" 1102 | - args: 1103 | - "double" 1104 | - "bigint" 1105 | return: "double" 1106 | - args: 1107 | - "float" 1108 | - "integer" 1109 | return: "float" 1110 | - args: 1111 | - "float" 1112 | - "bigint" 1113 | return: "float" 1114 | - args: 1115 | - "integer" 1116 | - "decimal" 1117 | return: "decimal" 1118 | - args: 1119 | - "decimal" 1120 | - "integer" 1121 | return: "decimal" 1122 | - args: 1123 | - "decimal" 1124 | - "decimal" 1125 | return: "decimal" 1126 | - names: 1127 | - "abs" #https://docs.snowflake.net/manuals/sql-reference/functions/abs.html 1128 | signatures: 1129 | - args: 1130 | - "integer" 1131 | return: "integer" 1132 | - args: 1133 | - "double" 1134 | return: "double" 1135 | - args: 1136 | - "bigint" 1137 | return: "bigint" 1138 | - args: 1139 | - "float" 1140 | return: "double" 1141 | - args: 1142 | - "decimal" 1143 | return: "decimal" 1144 | - names: 1145 | - "atan" #https://docs.snowflake.net/manuals/sql-reference/functions/atan.html 1146 | signatures: 1147 | - args: 1148 | - "bigint" 1149 | return: "double" 1150 | - args: 1151 | - "double" 1152 | return: "double" 1153 | - args: 1154 | - "float" 1155 | return: "double" 1156 | - args: 1157 | - "integer" 1158 | return: "double" 1159 | - args: 1160 | - "decimal" 1161 | return: "decimal" 1162 | - names: 1163 | - "atan2" #https://docs.snowflake.net/manuals/sql-reference/functions/atan2.html 1164 | signatures: 1165 | - args: 1166 | - "bigint" 1167 | - "float" 1168 | return: "double" 1169 | - args: 1170 | - "double" 1171 | - "double" 1172 | return: "double" 1173 | - args: 1174 | - "double" 1175 | - "bigint" 1176 | return: "double" 1177 | - args: 1178 | - "bigint" 1179 | - "integer" 1180 | return: "double" 1181 | - args: 1182 | - "integer" 1183 | - "bigint" 1184 | return: "double" 1185 | - args: 1186 | - "integer" 1187 | - "double" 1188 | return: "double" 1189 | - args: 1190 | - "float" 1191 | - "integer" 1192 | return: "double" 1193 | - args: 1194 | - "float" 1195 | - "float" 1196 | return: "double" 1197 | - args: 1198 | - "double" 1199 | - "float" 1200 | return: "double" 1201 | - args: 1202 | - "integer" 1203 | - "float" 1204 | return: "double" 1205 | - args: 1206 | - "bigint" 1207 | - "bigint" 1208 | return: "double" 1209 | - args: 1210 | - "float" 1211 | - "bigint" 1212 | return: "double" 1213 | - args: 1214 | - "float" 1215 | - "double" 1216 | return: "double" 1217 | - args: 1218 | - "bigint" 1219 | - "double" 1220 | return: "double" 1221 | - args: 1222 | - "integer" 1223 | - "integer" 1224 | return: "double" 1225 | - args: 1226 | - "double" 1227 | - "integer" 1228 | return: "double" 1229 | - args: 1230 | - "integer" 1231 | - "decimal" 1232 | return: "decimal" 1233 | - args: 1234 | - "decimal" 1235 | - "integer" 1236 | return: "decimal" 1237 | - args: 1238 | - "decimal" 1239 | - "decimal" 1240 | return: "decimal" 1241 | - names: 1242 | - "cbrt" #https://docs.snowflake.net/manuals/sql-reference/functions/cbrt.html 1243 | signatures: 1244 | - args: 1245 | - "bigint" 1246 | return: "double" 1247 | - args: 1248 | - "double" 1249 | return: "double" 1250 | - args: 1251 | - "float" 1252 | return: "double" 1253 | - args: 1254 | - "integer" 1255 | return: "double" 1256 | - args: 1257 | - "decimal" 1258 | return: "decimal" 1259 | - names: 1260 | - "ceil" #https://docs.snowflake.net/manuals/sql-reference/functions/ceil.html 1261 | signatures: 1262 | - args: 1263 | - "bigint" 1264 | return: "double" 1265 | - args: 1266 | - "double" 1267 | return: "double" 1268 | - args: 1269 | - "float" 1270 | return: "double" 1271 | - args: 1272 | - "integer" 1273 | return: "double" 1274 | - args: 1275 | - "decimal" 1276 | return: "decimal" 1277 | - names: 1278 | - "cos" #https://docs.snowflake.net/manuals/sql-reference/functions/cos.html 1279 | - "cosh" 1280 | signatures: 1281 | - args: 1282 | - "bigint" 1283 | return: "double" 1284 | - args: 1285 | - "double" 1286 | return: "double" 1287 | - args: 1288 | - "float" 1289 | return: "double" 1290 | - args: 1291 | - "integer" 1292 | return: "double" 1293 | - args: 1294 | - "decimal" 1295 | return: "decimal" 1296 | - names: 1297 | - "cot" #https://docs.snowflake.net/manuals/sql-reference/functions/cot.html 1298 | signatures: 1299 | - args: 1300 | - "bigint" 1301 | return: "double" 1302 | - args: 1303 | - "double" 1304 | return: "double" 1305 | - args: 1306 | - "float" 1307 | return: "double" 1308 | - args: 1309 | - "integer" 1310 | return: "double" 1311 | - args: 1312 | - "decimal" 1313 | return: "decimal" 1314 | - names: 1315 | - "degrees" #https://docs.snowflake.net/manuals/sql-reference/functions/degrees.html 1316 | signatures: 1317 | - args: 1318 | - "bigint" 1319 | return: "double" 1320 | - args: 1321 | - "double" 1322 | return: "double" 1323 | - args: 1324 | - "float" 1325 | return: "double" 1326 | - args: 1327 | - "integer" 1328 | return: "double" 1329 | - args: 1330 | - "decimal" 1331 | return: "decimal" 1332 | - names: 1333 | - "exp" #https://docs.snowflake.net/manuals/sql-reference/functions/exp.html 1334 | signatures: 1335 | - args: 1336 | - "float" 1337 | return: "double" 1338 | - args: 1339 | - "integer" 1340 | return: "double" 1341 | - args: 1342 | - "decimal" 1343 | return: "decimal" 1344 | - names: 1345 | - "ln" #https://docs.snowflake.net/manuals/sql-reference/functions/ln.html 1346 | signatures: 1347 | - args: 1348 | - "bigint" 1349 | return: "double" 1350 | - args: 1351 | - "double" 1352 | return: "double" 1353 | - args: 1354 | - "float" 1355 | return: "double" 1356 | - args: 1357 | - "integer" 1358 | return: "double" 1359 | - args: 1360 | - "decimal" 1361 | return: "decimal" 1362 | - names: 1363 | - "mod" #https://docs.snowflake.net/manuals/sql-reference/functions/mod.html 1364 | signatures: 1365 | - args: 1366 | - "double" 1367 | - "double" 1368 | return: "double" 1369 | - args: 1370 | - "double" 1371 | - "bigint" 1372 | return: "double" 1373 | - args: 1374 | - "integer" 1375 | - "double" 1376 | return: "double" 1377 | - args: 1378 | - "bigint" 1379 | - "bigint" 1380 | return: "bigint" 1381 | - args: 1382 | - "integer" 1383 | - "integer" 1384 | return: "integer" 1385 | - args: 1386 | - "bigint" 1387 | - "double" 1388 | return: "double" 1389 | - args: 1390 | - "bigint" 1391 | - "integer" 1392 | return: "integer" 1393 | - args: 1394 | - "double" 1395 | - "integer" 1396 | return: "double" 1397 | - args: 1398 | - "integer" 1399 | - "bigint" 1400 | return: "bigint" 1401 | - args: 1402 | - "integer" 1403 | - "decimal" 1404 | return: "decimal" 1405 | - args: 1406 | - "decimal" 1407 | - "integer" 1408 | return: "decimal" 1409 | - args: 1410 | - "decimal" 1411 | - "decimal" 1412 | return: "decimal" 1413 | - names: 1414 | - "power" #https://docs.snowflake.net/manuals/sql-reference/functions/pow.html 1415 | signatures: 1416 | - args: 1417 | - "bigint" 1418 | - "float" 1419 | return: "double" 1420 | - args: 1421 | - "bigint" 1422 | - "integer" 1423 | return: "double" 1424 | - args: 1425 | - "integer" 1426 | - "bigint" 1427 | return: "double" 1428 | - args: 1429 | - "integer" 1430 | - "double" 1431 | return: "double" 1432 | - args: 1433 | - "float" 1434 | - "integer" 1435 | return: "double" 1436 | - args: 1437 | - "float" 1438 | - "float" 1439 | return: "double" 1440 | - args: 1441 | - "double" 1442 | - "double" 1443 | return: "double" 1444 | - args: 1445 | - "integer" 1446 | - "integer" 1447 | return: "double" 1448 | - args: 1449 | - "double" 1450 | - "float" 1451 | return: "double" 1452 | - args: 1453 | - "double" 1454 | - "integer" 1455 | return: "double" 1456 | - args: 1457 | - "integer" 1458 | - "float" 1459 | return: "double" 1460 | - args: 1461 | - "integer" 1462 | - "decimal" 1463 | return: "decimal" 1464 | - args: 1465 | - "decimal" 1466 | - "integer" 1467 | return: "decimal" 1468 | - args: 1469 | - "decimal" 1470 | - "decimal" 1471 | return: "decimal" 1472 | - names: 1473 | - "radians" #https://docs.snowflake.net/manuals/sql-reference/functions/radians.html 1474 | signatures: 1475 | - args: 1476 | - "bigint" 1477 | return: "double" 1478 | - args: 1479 | - "double" 1480 | return: "double" 1481 | - args: 1482 | - "float" 1483 | return: "double" 1484 | - args: 1485 | - "integer" 1486 | return: "double" 1487 | - args: 1488 | - "decimal" 1489 | return: "decimal" 1490 | - names: 1491 | - "sin" #https://docs.snowflake.net/manuals/sql-reference/functions/sin.html 1492 | signatures: 1493 | - args: 1494 | - "bigint" 1495 | return: "double" 1496 | - args: 1497 | - "double" 1498 | return: "double" 1499 | - args: 1500 | - "float" 1501 | return: "double" 1502 | - args: 1503 | - "integer" 1504 | return: "double" 1505 | - args: 1506 | - "decimal" 1507 | return: "decimal" 1508 | - names: 1509 | - "sqrt" #https://docs.snowflake.net/manuals/sql-reference/functions/sqrt.html 1510 | signatures: 1511 | - args: 1512 | - "bigint" 1513 | return: "double" 1514 | - args: 1515 | - "double" 1516 | return: "double" 1517 | - args: 1518 | - "float" 1519 | return: "double" 1520 | - args: 1521 | - "integer" 1522 | return: "double" 1523 | - args: 1524 | - "decimal" 1525 | return: "decimal" 1526 | - names: 1527 | - "tan" #https://docs.snowflake.net/manuals/sql-reference/functions/tan.html 1528 | - "tanh" 1529 | signatures: 1530 | - args: 1531 | - "bigint" 1532 | return: "double" 1533 | - args: 1534 | - "double" 1535 | return: "double" 1536 | - args: 1537 | - "float" 1538 | return: "double" 1539 | - args: 1540 | - "integer" 1541 | return: "double" 1542 | - args: 1543 | - "decimal" 1544 | return: "decimal" 1545 | 1546 | #https://docs.snowflake.net/manuals/sql-reference/operators.html 1547 | #--- Arithmetic Operators --# 1548 | - names: 1549 | - "+" 1550 | - "-" 1551 | signatures: 1552 | - args: 1553 | - "decimal" 1554 | - "decimal" 1555 | return: "decimal" 1556 | - args: 1557 | - "decimal" 1558 | - "double" 1559 | return: "double" 1560 | - args: 1561 | - "decimal" 1562 | - "float" 1563 | return: "float" 1564 | - args: 1565 | - "decimal" 1566 | - "bigint" 1567 | return: "decimal" 1568 | - args: 1569 | - "decimal" 1570 | - "integer" 1571 | return: "decimal" 1572 | - args: 1573 | - "decimal" 1574 | - "boolean" 1575 | return: "decimal" 1576 | - args: 1577 | - "decimal" 1578 | - "varchar" 1579 | return: "decimal" 1580 | - args: 1581 | - "double" 1582 | - "double" 1583 | return: "double" 1584 | - args: 1585 | - "double" 1586 | - "decimal" 1587 | return: "double" 1588 | - args: 1589 | - "double" 1590 | - "float" 1591 | return: "double" 1592 | - args: 1593 | - "double" 1594 | - "bigint" 1595 | return: "double" 1596 | - args: 1597 | - "double" 1598 | - "integer" 1599 | return: "double" 1600 | - args: 1601 | - "double" 1602 | - "boolean" 1603 | return: "double" 1604 | - args: 1605 | - "double" 1606 | - "varchar" 1607 | return: "double" 1608 | - args: 1609 | - "float" 1610 | - "double" 1611 | return: "double" 1612 | - args: 1613 | - "float" 1614 | - "decimal" 1615 | return: "float" 1616 | - args: 1617 | - "float" 1618 | - "float" 1619 | return: "float" 1620 | - args: 1621 | - "float" 1622 | - "bigint" 1623 | return: "float" 1624 | - args: 1625 | - "float" 1626 | - "integer" 1627 | return: "float" 1628 | - args: 1629 | - "float" 1630 | - "boolean" 1631 | return: "float" 1632 | - args: 1633 | - "float" 1634 | - "varchar" 1635 | return: "float" 1636 | - args: 1637 | - "bigint" 1638 | - "bigint" 1639 | return: "bigint" 1640 | - args: 1641 | - "bigint" 1642 | - "decimal" 1643 | return: "decimal" 1644 | - args: 1645 | - "bigint" 1646 | - "double" 1647 | return: "double" 1648 | - args: 1649 | - "bigint" 1650 | - "float" 1651 | return: "float" 1652 | - args: 1653 | - "bigint" 1654 | - "integer" 1655 | return: "bigint" 1656 | - args: 1657 | - "bigint" 1658 | - "boolean" 1659 | return: "bigint" 1660 | - args: 1661 | - "bigint" 1662 | - "varchar" 1663 | return: "bigint" 1664 | - args: 1665 | - "integer" 1666 | - "integer" 1667 | return: "integer" 1668 | - args: 1669 | - "integer" 1670 | - "decimal" 1671 | return: "decimal" 1672 | - args: 1673 | - "integer" 1674 | - "double" 1675 | return: "double" 1676 | - args: 1677 | - "integer" 1678 | - "float" 1679 | return: "float" 1680 | - args: 1681 | - "integer" 1682 | - "bigint" 1683 | return: "bigint" 1684 | - args: 1685 | - "integer" 1686 | - "boolean" 1687 | return: "integer" 1688 | - args: 1689 | - "integer" 1690 | - "varchar" 1691 | return: "integer" 1692 | - args: 1693 | - "varchar" 1694 | - "varchar" 1695 | return: "varchar" 1696 | - args: 1697 | - "varchar" 1698 | - "decimal" 1699 | return: "decimal" 1700 | - args: 1701 | - "varchar" 1702 | - "double" 1703 | return: "double" 1704 | - args: 1705 | - "varchar" 1706 | - "bigint" 1707 | return: "bigint" 1708 | - args: 1709 | - "varchar" 1710 | - "integer" 1711 | return: "integer" 1712 | - args: 1713 | - "boolean" 1714 | - "decimal" 1715 | return: "decimal" 1716 | - args: 1717 | - "boolean" 1718 | - "double" 1719 | return: "double" 1720 | - args: 1721 | - "boolean" 1722 | - "bigint" 1723 | return: "bigint" 1724 | - args: 1725 | - "boolean" 1726 | - "integer" 1727 | return: "integer" 1728 | - args: 1729 | - "timestamp" 1730 | - "timestamp" 1731 | return: "timestamp" 1732 | - names: 1733 | - "/" 1734 | signatures: 1735 | - args: 1736 | - "decimal" 1737 | - "decimal" 1738 | return: "decimal" 1739 | - args: 1740 | - "decimal" 1741 | - "double" 1742 | return: "double" 1743 | - args: 1744 | - "decimal" 1745 | - "float" 1746 | return: "double" 1747 | - args: 1748 | - "decimal" 1749 | - "bigint" 1750 | return: "decimal" 1751 | - args: 1752 | - "decimal" 1753 | - "integer" 1754 | return: "decimal" 1755 | - args: 1756 | - "decimal" 1757 | - "boolean" 1758 | return: "decimal" 1759 | - args: 1760 | - "decimal" 1761 | - "varchar" 1762 | return: "decimal" 1763 | - args: 1764 | - "double" 1765 | - "double" 1766 | return: "double" 1767 | - args: 1768 | - "double" 1769 | - "decimal" 1770 | return: "double" 1771 | - args: 1772 | - "double" 1773 | - "float" 1774 | return: "double" 1775 | - args: 1776 | - "double" 1777 | - "bigint" 1778 | return: "double" 1779 | - args: 1780 | - "double" 1781 | - "integer" 1782 | return: "double" 1783 | - args: 1784 | - "double" 1785 | - "boolean" 1786 | return: "double" 1787 | - args: 1788 | - "double" 1789 | - "varchar" 1790 | return: "double" 1791 | - args: 1792 | - "float" 1793 | - "double" 1794 | return: "double" 1795 | - args: 1796 | - "float" 1797 | - "decimal" 1798 | return: "float" 1799 | - args: 1800 | - "float" 1801 | - "float" 1802 | return: "float" 1803 | - args: 1804 | - "float" 1805 | - "bigint" 1806 | return: "double" 1807 | - args: 1808 | - "float" 1809 | - "integer" 1810 | return: "float" 1811 | - args: 1812 | - "float" 1813 | - "boolean" 1814 | return: "float" 1815 | - args: 1816 | - "float" 1817 | - "varchar" 1818 | return: "float" 1819 | - args: 1820 | - "bigint" 1821 | - "bigint" 1822 | return: "bigint" 1823 | - args: 1824 | - "bigint" 1825 | - "decimal" 1826 | return: "decimal" 1827 | - args: 1828 | - "bigint" 1829 | - "double" 1830 | return: "double" 1831 | - args: 1832 | - "bigint" 1833 | - "float" 1834 | return: "double" 1835 | - args: 1836 | - "bigint" 1837 | - "integer" 1838 | return: "bigint" 1839 | - args: 1840 | - "bigint" 1841 | - "boolean" 1842 | return: "bigint" 1843 | - args: 1844 | - "bigint" 1845 | - "varchar" 1846 | return: "bigint" 1847 | - args: 1848 | - "integer" 1849 | - "integer" 1850 | return: "integer" 1851 | - args: 1852 | - "integer" 1853 | - "decimal" 1854 | return: "decimal" 1855 | - args: 1856 | - "integer" 1857 | - "double" 1858 | return: "double" 1859 | - args: 1860 | - "integer" 1861 | - "float" 1862 | return: "float" 1863 | - args: 1864 | - "integer" 1865 | - "bigint" 1866 | return: "bigint" 1867 | - args: 1868 | - "integer" 1869 | - "boolean" 1870 | return: "integer" 1871 | - args: 1872 | - "integer" 1873 | - "varchar" 1874 | return: "integer" 1875 | - args: 1876 | - "varchar" 1877 | - "decimal" 1878 | return: "decimal" 1879 | - args: 1880 | - "varchar" 1881 | - "double" 1882 | return: "double" 1883 | - args: 1884 | - "varchar" 1885 | - "float" 1886 | return: "float" 1887 | - args: 1888 | - "varchar" 1889 | - "bigint" 1890 | return: "bigint" 1891 | - args: 1892 | - "varchar" 1893 | - "integer" 1894 | return: "integer" 1895 | - args: 1896 | - "boolean" 1897 | - "double" 1898 | return: "double" 1899 | - args: 1900 | - "boolean" 1901 | - "float" 1902 | return: "float" 1903 | - args: 1904 | - "boolean" 1905 | - "bigint" 1906 | return: "bigint" 1907 | - args: 1908 | - "boolean" 1909 | - "integer" 1910 | return: "integer" 1911 | - names: 1912 | - "*" 1913 | signatures: 1914 | - args: 1915 | - "decimal" 1916 | - "decimal" 1917 | return: "decimal" 1918 | - args: 1919 | - "decimal" 1920 | - "double" 1921 | return: "double" 1922 | - args: 1923 | - "decimal" 1924 | - "float" 1925 | return: "double" 1926 | - args: 1927 | - "decimal" 1928 | - "bigint" 1929 | return: "decimal" 1930 | - args: 1931 | - "decimal" 1932 | - "integer" 1933 | return: "decimal" 1934 | - args: 1935 | - "decimal" 1936 | - "boolean" 1937 | return: "decimal" 1938 | - args: 1939 | - "decimal" 1940 | - "varchar" 1941 | return: "decimal" 1942 | - args: 1943 | - "double" 1944 | - "double" 1945 | return: "double" 1946 | - args: 1947 | - "double" 1948 | - "decimal" 1949 | return: "double" 1950 | - args: 1951 | - "double" 1952 | - "float" 1953 | return: "double" 1954 | - args: 1955 | - "double" 1956 | - "bigint" 1957 | return: "double" 1958 | - args: 1959 | - "double" 1960 | - "integer" 1961 | return: "double" 1962 | - args: 1963 | - "double" 1964 | - "boolean" 1965 | return: "double" 1966 | - args: 1967 | - "double" 1968 | - "varchar" 1969 | return: "double" 1970 | - args: 1971 | - "float" 1972 | - "double" 1973 | return: "double" 1974 | - args: 1975 | - "float" 1976 | - "decimal" 1977 | return: "float" 1978 | - args: 1979 | - "float" 1980 | - "float" 1981 | return: "float" 1982 | - args: 1983 | - "float" 1984 | - "bigint" 1985 | return: "double" 1986 | - args: 1987 | - "float" 1988 | - "integer" 1989 | return: "float" 1990 | - args: 1991 | - "float" 1992 | - "boolean" 1993 | return: "float" 1994 | - args: 1995 | - "float" 1996 | - "varchar" 1997 | return: "float" 1998 | - args: 1999 | - "bigint" 2000 | - "bigint" 2001 | return: "bigint" 2002 | - args: 2003 | - "bigint" 2004 | - "decimal" 2005 | return: "decimal" 2006 | - args: 2007 | - "bigint" 2008 | - "double" 2009 | return: "double" 2010 | - args: 2011 | - "bigint" 2012 | - "float" 2013 | return: "double" 2014 | - args: 2015 | - "bigint" 2016 | - "integer" 2017 | return: "bigint" 2018 | - args: 2019 | - "bigint" 2020 | - "boolean" 2021 | return: "bigint" 2022 | - args: 2023 | - "bigint" 2024 | - "varchar" 2025 | return: "bigint" 2026 | - args: 2027 | - "integer" 2028 | - "integer" 2029 | return: "integer" 2030 | - args: 2031 | - "integer" 2032 | - "decimal" 2033 | return: "decimal" 2034 | - args: 2035 | - "integer" 2036 | - "double" 2037 | return: "double" 2038 | - args: 2039 | - "integer" 2040 | - "float" 2041 | return: "float" 2042 | - args: 2043 | - "integer" 2044 | - "bigint" 2045 | return: "bigint" 2046 | - args: 2047 | - "integer" 2048 | - "boolean" 2049 | return: "integer" 2050 | - args: 2051 | - "integer" 2052 | - "varchar" 2053 | return: "integer" 2054 | - args: 2055 | - "varchar" 2056 | - "decimal" 2057 | return: "decimal" 2058 | - args: 2059 | - "varchar" 2060 | - "double" 2061 | return: "double" 2062 | - args: 2063 | - "varchar" 2064 | - "float" 2065 | return: "float" 2066 | - args: 2067 | - "varchar" 2068 | - "bigint" 2069 | return: "bigint" 2070 | - args: 2071 | - "varchar" 2072 | - "integer" 2073 | return: "integer" 2074 | - args: 2075 | - "boolean" 2076 | - "double" 2077 | return: "double" 2078 | - args: 2079 | - "boolean" 2080 | - "float" 2081 | return: "float" 2082 | - args: 2083 | - "boolean" 2084 | - "bigint" 2085 | return: "bigint" 2086 | - args: 2087 | - "boolean" 2088 | - "integer" 2089 | return: "integer" 2090 | #--- Null type ---# 2091 | - names: 2092 | - "is null" 2093 | signatures: 2094 | - args: 2095 | - "float" 2096 | return: "boolean" 2097 | - args: 2098 | - "integer" 2099 | return: "boolean" 2100 | - args: 2101 | - "time" 2102 | return: "boolean" 2103 | - args: 2104 | - "varbinary" 2105 | return: "boolean" 2106 | - args: 2107 | - "timestamp" 2108 | return: "boolean" 2109 | - args: 2110 | - "boolean" 2111 | return: "boolean" 2112 | - args: 2113 | - "date" 2114 | return: "boolean" 2115 | - args: 2116 | - "double" 2117 | return: "boolean" 2118 | - args: 2119 | - "varchar" 2120 | return: "boolean" 2121 | - args: 2122 | - "bigint" 2123 | return: "boolean" 2124 | - args: 2125 | - "decimal" 2126 | return: "boolean" 2127 | - names: 2128 | - "is not null" 2129 | signatures: 2130 | - args: 2131 | - "float" 2132 | return: "boolean" 2133 | - args: 2134 | - "integer" 2135 | return: "boolean" 2136 | - args: 2137 | - "time" 2138 | return: "boolean" 2139 | - args: 2140 | - "varbinary" 2141 | return: "boolean" 2142 | - args: 2143 | - "timestamp" 2144 | return: "boolean" 2145 | - args: 2146 | - "boolean" 2147 | return: "boolean" 2148 | - args: 2149 | - "date" 2150 | return: "boolean" 2151 | - args: 2152 | - "double" 2153 | return: "boolean" 2154 | - args: 2155 | - "varchar" 2156 | return: "boolean" 2157 | - args: 2158 | - "bigint" 2159 | return: "boolean" 2160 | - args: 2161 | - "decimal" 2162 | return: "boolean" 2163 | 2164 | #--- Relational Operators --# 2165 | - names: 2166 | - "=" 2167 | - "!=" 2168 | - "<>" 2169 | - ">" 2170 | - ">=" 2171 | - "<" 2172 | - "<=" 2173 | signatures: 2174 | - args: 2175 | - "decimal" 2176 | - "decimal" 2177 | return: "boolean" 2178 | - args: 2179 | - "decimal" 2180 | - "double" 2181 | return: "boolean" 2182 | - args: 2183 | - "decimal" 2184 | - "float" 2185 | return: "boolean" 2186 | - args: 2187 | - "decimal" 2188 | - "bigint" 2189 | return: "boolean" 2190 | - args: 2191 | - "decimal" 2192 | - "integer" 2193 | return: "boolean" 2194 | - args: 2195 | - "decimal" 2196 | - "varchar" 2197 | return: "boolean" 2198 | - args: 2199 | - "double" 2200 | - "double" 2201 | return: "boolean" 2202 | - args: 2203 | - "double" 2204 | - "decimal" 2205 | return: "boolean" 2206 | - args: 2207 | - "double" 2208 | - "float" 2209 | return: "boolean" 2210 | - args: 2211 | - "double" 2212 | - "bigint" 2213 | return: "boolean" 2214 | - args: 2215 | - "double" 2216 | - "integer" 2217 | return: "boolean" 2218 | - args: 2219 | - "double" 2220 | - "varchar" 2221 | return: "boolean" 2222 | - args: 2223 | - "float" 2224 | - "float" 2225 | return: "boolean" 2226 | - args: 2227 | - "float" 2228 | - "decimal" 2229 | return: "boolean" 2230 | - args: 2231 | - "float" 2232 | - "double" 2233 | return: "boolean" 2234 | - args: 2235 | - "float" 2236 | - "bigint" 2237 | return: "boolean" 2238 | - args: 2239 | - "float" 2240 | - "integer" 2241 | return: "boolean" 2242 | - args: 2243 | - "float" 2244 | - "varchar" 2245 | return: "boolean" 2246 | - args: 2247 | - "bigint" 2248 | - "bigint" 2249 | return: "boolean" 2250 | - args: 2251 | - "bigint" 2252 | - "decimal" 2253 | return: "boolean" 2254 | - args: 2255 | - "bigint" 2256 | - "double" 2257 | return: "boolean" 2258 | - args: 2259 | - "bigint" 2260 | - "float" 2261 | return: "boolean" 2262 | - args: 2263 | - "bigint" 2264 | - "integer" 2265 | return: "boolean" 2266 | - args: 2267 | - "bigint" 2268 | - "varchar" 2269 | return: "boolean" 2270 | - args: 2271 | - "integer" 2272 | - "integer" 2273 | return: "boolean" 2274 | - args: 2275 | - "integer" 2276 | - "decimal" 2277 | return: "boolean" 2278 | - args: 2279 | - "integer" 2280 | - "double" 2281 | return: "boolean" 2282 | - args: 2283 | - "integer" 2284 | - "float" 2285 | return: "boolean" 2286 | - args: 2287 | - "integer" 2288 | - "bigint" 2289 | return: "boolean" 2290 | - args: 2291 | - "integer" 2292 | - "varchar" 2293 | return: "boolean" 2294 | - args: 2295 | - "varchar" 2296 | - "varchar" 2297 | return: "boolean" 2298 | - args: 2299 | - "varchar" 2300 | - "decimal" 2301 | return: "boolean" 2302 | - args: 2303 | - "varchar" 2304 | - "double" 2305 | return: "boolean" 2306 | - args: 2307 | - "varchar" 2308 | - "float" 2309 | return: "boolean" 2310 | - args: 2311 | - "varchar" 2312 | - "bigint" 2313 | return: "boolean" 2314 | - args: 2315 | - "varchar" 2316 | - "integer" 2317 | return: "boolean" 2318 | - args: 2319 | - "varchar" 2320 | - "date" 2321 | return: "boolean" 2322 | - args: 2323 | - "varchar" 2324 | - "time" 2325 | return: "boolean" 2326 | - args: 2327 | - "varchar" 2328 | - "timestamp" 2329 | return: "boolean" 2330 | - args: 2331 | - "date" 2332 | - "date" 2333 | return: "boolean" 2334 | - args: 2335 | - "date" 2336 | - "timestamp" 2337 | return: "boolean" 2338 | - args: 2339 | - "date" 2340 | - "varchar" 2341 | return: "boolean" 2342 | - args: 2343 | - "timestamp" 2344 | - "date" 2345 | return: "boolean" 2346 | - args: 2347 | - "timestamp" 2348 | - "timestamp" 2349 | return: "boolean" 2350 | - args: 2351 | - "timestamp" 2352 | - "varchar" 2353 | return: "boolean" 2354 | - args: 2355 | - "time" 2356 | - "time" 2357 | return: "boolean" 2358 | - args: 2359 | - "time" 2360 | - "timestamp" 2361 | return: "boolean" 2362 | - args: 2363 | - "time" 2364 | - "varchar" 2365 | return: "boolean" 2366 | - args: 2367 | - "varbinary" 2368 | - "varbinary" 2369 | return: "boolean" 2370 | - args: 2371 | - "boolean" 2372 | - "boolean" 2373 | return: "boolean" 2374 | - names: 2375 | - "like" 2376 | signatures: 2377 | - args: 2378 | - "varchar" 2379 | - "varchar" 2380 | return: "boolean" 2381 | - args: 2382 | - "varbinary" 2383 | - "varbinary" 2384 | return: "boolean" 2385 | - args: 2386 | - "varchar" 2387 | - "varchar" 2388 | - "varchar" # The escape modifier character 2389 | return: "boolean" 2390 | rewrite: "{0} like {1} ESCAPE {2}" 2391 | - args: 2392 | - "varbinary" 2393 | - "varbinary" 2394 | - "varchar" # The escape modifier character 2395 | return: "boolean" 2396 | rewrite: "{0} like {1} ESCAPE {2}" 2397 | - names: 2398 | - "not" 2399 | signatures: 2400 | - args: 2401 | - "boolean" 2402 | return: "boolean" 2403 | - names: 2404 | - "||" 2405 | signatures: 2406 | - args: 2407 | - "time" 2408 | - "varchar" 2409 | return: "varchar" 2410 | - args: 2411 | - "varchar" 2412 | - "date" 2413 | return: "varchar" 2414 | - args: 2415 | - "varchar" 2416 | - "float" 2417 | return: "varchar" 2418 | - args: 2419 | - "varchar" 2420 | - "timestamp" 2421 | return: "varchar" 2422 | - args: 2423 | - "varchar" 2424 | - "varchar" 2425 | return: "varchar" 2426 | - args: 2427 | - "varchar" 2428 | - "integer" 2429 | return: "varchar" 2430 | - args: 2431 | - "varchar" 2432 | - "boolean" 2433 | return: "varchar" 2434 | - args: 2435 | - "varchar" 2436 | - "varbinary" 2437 | return: "varchar" 2438 | - args: 2439 | - "varchar" 2440 | - "time" 2441 | return: "varchar" 2442 | - args: 2443 | - "boolean" 2444 | - "varchar" 2445 | return: "varchar" 2446 | - args: 2447 | - "varchar" 2448 | - "double" 2449 | return: "varchar" 2450 | - args: 2451 | - "float" 2452 | - "varchar" 2453 | return: "varchar" 2454 | - args: 2455 | - "bigint" 2456 | - "varchar" 2457 | return: "varchar" 2458 | - args: 2459 | - "varbinary" 2460 | - "varbinary" 2461 | return: "varbinary" 2462 | - args: 2463 | - "varbinary" 2464 | - "varchar" 2465 | return: "varchar" 2466 | - args: 2467 | - "timestamp" 2468 | - "varchar" 2469 | return: "varchar" 2470 | - args: 2471 | - "double" 2472 | - "varchar" 2473 | return: "varchar" 2474 | - args: 2475 | - "date" 2476 | - "varchar" 2477 | return: "varchar" 2478 | - args: 2479 | - "varchar" 2480 | - "bigint" 2481 | return: "varchar" 2482 | - args: 2483 | - "integer" 2484 | - "varchar" 2485 | return: "varchar" 2486 | - args: 2487 | - "double" 2488 | - "double" 2489 | return: "varchar" 2490 | - args: 2491 | - "decimal" 2492 | - "decimal" 2493 | return: "varchar" 2494 | - names: 2495 | - "or" 2496 | signatures: 2497 | - args: 2498 | - "boolean" 2499 | - "boolean" 2500 | return: "boolean" 2501 | 2502 | variable_length_operators: 2503 | - names: 2504 | - and 2505 | variable_signatures: 2506 | - return: boolean 2507 | arg_type: boolean 2508 | - names: 2509 | - or 2510 | variable_signatures: 2511 | - return: boolean 2512 | arg_type: boolean 2513 | - names: 2514 | - concat 2515 | variable_signatures: 2516 | - return: varchar 2517 | arg_type: varchar 2518 | --------------------------------------------------------------------------------