mistercrunch closed pull request #4882: Implement Snowflake engine with 
supported time grains
URL: https://github.com/apache/incubator-superset/pull/4882
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/docs/installation.rst b/docs/installation.rst
index be4abe8168..ca9cf3f595 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 0c7444c3f0..49dd39cd6d 100644
--- a/superset/db_engine_specs.py
+++ b/superset/db_engine_specs.py
@@ -334,6 +334,22 @@ def get_table_names(cls, schema, inspector):
         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'
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to