You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2023/11/09 03:45:46 UTC
(superset) 01/01: feat(metadb): handle decimals
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 02d37746a7d9e0615230fdfda077c17616003dc5
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Wed Nov 8 22:44:37 2023 -0500
feat(metadb): handle decimals
---
requirements/base.txt | 2 +-
requirements/testing.txt | 2 +-
setup.py | 6 +++---
superset/extensions/metadb.py | 15 +++++++++++++--
4 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/requirements/base.txt b/requirements/base.txt
index d056b403c3..33c16bbf10 100644
--- a/requirements/base.txt
+++ b/requirements/base.txt
@@ -290,7 +290,7 @@ rich==13.3.4
# via flask-limiter
selenium==3.141.0
# via apache-superset
-shillelagh==1.2.6
+shillelagh==1.2.9
# via apache-superset
shortid==0.1.2
# via apache-superset
diff --git a/requirements/testing.txt b/requirements/testing.txt
index 00fe734540..2f1de0d748 100644
--- a/requirements/testing.txt
+++ b/requirements/testing.txt
@@ -144,7 +144,7 @@ rsa==4.9
# via google-auth
setuptools-git==1.2
# via prophet
-shillelagh[gsheetsapi]==1.2.6
+shillelagh[gsheetsapi]==1.2.9
# via apache-superset
sqlalchemy-bigquery==1.6.1
# via apache-superset
diff --git a/setup.py b/setup.py
index 5173ad6dea..99d9cd5f6a 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.9,<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.9, <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.9,<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