superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: Implement Snowflake engine with supported time grains (#4882)
Date Wed, 25 Apr 2018 21:44:28 GMT
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new fa3da8c  Implement Snowflake engine with supported time grains (#4882)
fa3da8c is described below

commit fa3da8c888e25b62e72faaab8987631f07096b56
Author: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
AuthorDate: Thu Apr 26 00:44:24 2018 +0300

    Implement Snowflake engine with supported time grains (#4882)
    
    * Implement Snowflake engine with supported time grains
    
    * Fix typo in second grain
---
 docs/installation.rst       |  2 ++
 superset/db_engine_specs.py | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/docs/installation.rst b/docs/installation.rst
index be4abe8..ca9cf3f 100644
--- a/docs/installation.rst
+++ b/docs/installation.rst
@@ -298,6 +298,8 @@ Here's a list of some of the recommended packages.
 +---------------+-------------------------------------+-------------------------------------------------+
 |  sqlite       |                                     | ``sqlite://``                   
               |
 +---------------+-------------------------------------+-------------------------------------------------+
+|  Snowflake    | ``pip install snowflake-sqlalchemy``| ``snowflake://``                
               |
++---------------+-------------------------------------+-------------------------------------------------+
 |  Redshift     | ``pip install sqlalchemy-redshift`` | ``redshift+psycopg2://``        
               |
 +---------------+-------------------------------------+-------------------------------------------------+
 |  MSSQL        | ``pip install pymssql``             | ``mssql://``                    
               |
diff --git a/superset/db_engine_specs.py b/superset/db_engine_specs.py
index 0c7444c..49dd39c 100644
--- a/superset/db_engine_specs.py
+++ b/superset/db_engine_specs.py
@@ -334,6 +334,22 @@ class PostgresEngineSpec(PostgresBaseEngineSpec):
         return sorted(tables)
 
 
+class SnowflakeEngineSpec(PostgresBaseEngineSpec):
+    engine = 'snowflake'
+
+    time_grains = (
+        Grain('Time Column', _('Time Column'), '{col}', None),
+        Grain('second', _('second'), "DATE_TRUNC('SECOND', {col})", 'PT1S'),
+        Grain('minute', _('minute'), "DATE_TRUNC('MINUTE', {col})", 'PT1M'),
+        Grain('hour', _('hour'), "DATE_TRUNC('HOUR', {col})", 'PT1H'),
+        Grain('day', _('day'), "DATE_TRUNC('DAY', {col})", 'P1D'),
+        Grain('week', _('week'), "DATE_TRUNC('WEEK', {col})", 'P1W'),
+        Grain('month', _('month'), "DATE_TRUNC('MONTH', {col})", 'P1M'),
+        Grain('quarter', _('quarter'), "DATE_TRUNC('QUARTER', {col})", 'P0.25Y'),
+        Grain('year', _('year'), "DATE_TRUNC('YEAR', {col})", 'P1Y'),
+    )
+
+
 class VerticaEngineSpec(PostgresBaseEngineSpec):
     engine = 'vertica'
 

-- 
To stop receiving notification emails like this one, please contact
maximebeauchemin@apache.org.

Mime
View raw message