This is an automated email from the ASF dual-hosted git repository.

beto pushed a commit to branch fix-numeric
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 1a04f44282a47e5382b8093b732e54779f61f859
Author: Beto Dealmeida <[email protected]>
AuthorDate: Wed Nov 8 22:44:37 2023 -0500

    feat(metadb): handle decimals
---
 setup.py                      |  6 +++---
 superset/extensions/metadb.py | 15 +++++++++++++--
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/setup.py b/setup.py
index 88f2c0fba5..bc92e16aa0 100644
--- a/setup.py
+++ b/setup.py
@@ -118,7 +118,7 @@ setup(
         "PyJWT>=2.4.0, <3.0",
         "redis>=4.5.4, <5.0",
         "selenium>=3.141.0, <4.10.0",
-        "shillelagh>=1.2.6,<2.0",
+        "shillelagh>=1.2.10,<2.0",
         "shortid",
         "sshtunnel>=0.4.0, <0.5",
         "simplejson>=3.15.0",
@@ -162,7 +162,7 @@ setup(
         "excel": ["xlrd>=1.2.0, <1.3"],
         "firebird": ["sqlalchemy-firebird>=0.7.0, <0.8"],
         "firebolt": ["firebolt-sqlalchemy>=0.0.1"],
-        "gsheets": ["shillelagh[gsheetsapi]>=1.2.6, <2"],
+        "gsheets": ["shillelagh[gsheetsapi]>=1.2.10, <2"],
         "hana": ["hdbcli==2.4.162", "sqlalchemy_hana==0.4.0"],
         "hive": [
             "pyhive[hive]>=0.6.5;python_version<'3.11'",
@@ -191,7 +191,7 @@ setup(
         "redshift": ["sqlalchemy-redshift>=0.8.1, < 0.9"],
         "rockset": ["rockset-sqlalchemy>=0.0.1, <1.0.0"],
         "shillelagh": [
-            "shillelagh[datasetteapi,gsheetsapi,socrata,weatherapi]>=1.2.6,<2"
+            "shillelagh[datasetteapi,gsheetsapi,socrata,weatherapi]>=1.2.10,<2"
         ],
         "snowflake": ["snowflake-sqlalchemy>=1.2.4, <2"],
         "spark": [
diff --git a/superset/extensions/metadb.py b/superset/extensions/metadb.py
index 5b014b7af6..305ac86dd0 100644
--- a/superset/extensions/metadb.py
+++ b/superset/extensions/metadb.py
@@ -38,6 +38,7 @@ joins and unions are done in memory, using the SQLite engine.
 from __future__ import annotations
 
 import datetime
+import decimal
 import operator
 import urllib.parse
 from collections.abc import Iterator
@@ -86,7 +87,7 @@ class SupersetAPSWDialect(APSWDialect):
 
     Queries can also join data across different Superset databases.
 
-    The dialect is built in top of the shillelagh library, leveraging SQLite to
+    The dialect is built in top of the Shillelagh library, leveraging SQLite to
     create virtual tables on-the-fly proxying Superset tables. The
     `SupersetShillelaghAdapter` adapter is responsible for returning data when 
a
     Superset table is accessed.
@@ -164,11 +165,20 @@ class Duration(Field[datetime.timedelta, 
datetime.timedelta]):
     db_api_type = "DATETIME"
 
 
+class Decimal(Field[decimal.Decimal, decimal.Decimal]):
+    """
+    Shillelagh field used for representing decimals.
+    """
+
+    type = "DECIMAL"
+    db_api_type = "NUMBER"
+
+
 # pylint: disable=too-many-instance-attributes
 class SupersetShillelaghAdapter(Adapter):
 
     """
-    A shillelagh adapter for Superset tables.
+    A Shillelagh adapter for Superset tables.
 
     Shillelagh adapters are responsible for fetching data from a given 
resource,
     allowing it to be represented as a virtual table in SQLite. This one works
@@ -190,6 +200,7 @@ class SupersetShillelaghAdapter(Adapter):
         datetime.datetime: DateTime,
         datetime.time: Time,
         datetime.timedelta: Duration,
+        decimal.Decimal: Decimal,
     }
 
     @staticmethod

Reply via email to