You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2026/10/12 17:58:02 UTC
(superset) branch 7.0 updated (f6adeb15e3a -> 44dbb00d6a9)
This is an automated email from the ASF dual-hosted git repository.
villebro pushed a change to branch 7.0
in repository https://gitbox.apache.org/repos/asf/superset.git
from f6adeb15e3a fix(tests): import pytest in result_set_test for the #44189 backport
new 733ad716c3e fix(column-config): allow commas in D3 number formats (#45145)
new 4035ed96ae0 fix(bigquery): filter __NULL__ and __UNPARTITIONED__ from max partition query (#44156)
new ee6bb3ab198 fix(histogram): normalize before accumulating a cumulative histogram (#44652)
new 1f58f34e90d fix(databricks): enable equality operators for boolean filters (#36765) (#44355)
new 44dbb00d6a9 fix(deps): bump handlebars to 4.7.10 (handlebars part of #45143)
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
superset-frontend/package-lock.json | 48 ++++++--
superset-frontend/package.json | 2 +-
.../src/utils/D3Formatting.ts | 1 +
.../packages/superset-ui-core/package.json | 2 +-
.../plugins/plugin-chart-handlebars/package.json | 2 +-
.../plugins/preset-chart-deckgl/package.json | 2 +-
.../ColumnConfigConstants.test.tsx | 25 ++--
.../controls/ColumnConfigControl/constants.tsx | 2 +
superset/db_engine_specs/base.py | 19 +++
superset/db_engine_specs/bigquery.py | 20 +++-
superset/db_engine_specs/databricks.py | 37 +++++-
superset/db_engine_specs/spark.py | 18 +++
superset/models/helpers.py | 5 +-
superset/utils/pandas_postprocessing/histogram.py | 8 +-
tests/unit_tests/db_engine_specs/test_bigquery.py | 86 ++++++++++++-
.../unit_tests/db_engine_specs/test_databricks.py | 133 ++++++++++++++++++++-
tests/unit_tests/models/helpers_test.py | 42 +++++++
.../pandas_postprocessing/test_histogram.py | 32 +++--
18 files changed, 430 insertions(+), 54 deletions(-)
(superset) 05/05: fix(deps): bump handlebars to 4.7.10 (handlebars part of #45143)
Posted by vi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
villebro pushed a commit to branch 7.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 44dbb00d6a9050988f1e7f564065aee2f806fc68
Author: Ville Brofeldt <vi...@gmail.com>
AuthorDate: Mon Oct 12 09:51:35 2026 -0700
fix(deps): bump handlebars to 4.7.10 (handlebars part of #45143)
handlebars <= 4.7.9 is affected by GHSA-8r5x-fm3f-whwj and
GHSA-p8wg-vrv2-v86f (critical, JavaScript injection) and
GHSA-xw65-4hp5-5hc7 (medium); 4.7.10 fixes them. The Handlebars chart
plugin, the deck.gl tooltip renderer and Matrixify compile templates with it.
Takes only the handlebars changes from the security-group bump #45143
(8318398da4): the package ranges and the lockfile entries, including the
nested 4.7.9 copy lerna pins. Its other updates are dev tooling or docs
(concurrently, yeoman-generator 9 -> 10 for generator-superset,
webpack-dev-middleware) and conflict with 7.0's older generator-superset
dependencies, so they are left out.
---
superset-frontend/package-lock.json | 48 ++++++++++++++++++----
superset-frontend/package.json | 2 +-
.../packages/superset-ui-core/package.json | 2 +-
.../plugins/plugin-chart-handlebars/package.json | 2 +-
.../plugins/preset-chart-deckgl/package.json | 2 +-
5 files changed, 44 insertions(+), 12 deletions(-)
diff --git a/superset-frontend/package-lock.json b/superset-frontend/package-lock.json
index de93932577f..d64149e35ea 100644
--- a/superset-frontend/package-lock.json
+++ b/superset-frontend/package-lock.json
@@ -291,7 +291,7 @@
"peerDependencies": {
"ace-builds": "^1.41.0",
"core-js": "^3.38.1",
- "handlebars": "^4.7.8",
+ "handlebars": "^4.7.10",
"react-ace": "^10.1.0",
"regenerator-runtime": "^0.14.1"
}
@@ -24849,12 +24849,12 @@
}
},
"node_modules/handlebars": {
- "version": "4.7.9",
- "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.9.tgz",
- "integrity": "sha512-4E71E0rpOaQuJR2A3xDZ+GM1HyWYv1clR58tC8emQNeQe3RH7MAzSbat+V0wG78LQBo6m6bzSG/L4pBuCsgnUQ==",
+ "version": "4.7.10",
+ "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.10.tgz",
+ "integrity": "sha512-P5VJMVM7qgBn6vjXMw8WG9uVI+ncf2pi72j4de4yz5ZULLj2RGqLYaKOYGsgyrViQ0tePOVlN1tDCCXXtFqXKg==",
"license": "MIT",
"dependencies": {
- "minimist": "^1.2.5",
+ "minimist": "^1.2.8",
"neo-async": "^2.6.2",
"source-map": "^0.6.1",
"wordwrap": "^1.0.0"
@@ -31709,6 +31709,28 @@
}
}
},
+ "node_modules/lerna/node_modules/handlebars": {
+ "version": "4.7.9",
+ "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.9.tgz",
+ "integrity": "sha512-4E71E0rpOaQuJR2A3xDZ+GM1HyWYv1clR58tC8emQNeQe3RH7MAzSbat+V0wG78LQBo6m6bzSG/L4pBuCsgnUQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "minimist": "^1.2.5",
+ "neo-async": "^2.6.2",
+ "source-map": "^0.6.1",
+ "wordwrap": "^1.0.0"
+ },
+ "bin": {
+ "handlebars": "bin/handlebars"
+ },
+ "engines": {
+ "node": ">=0.4.7"
+ },
+ "optionalDependencies": {
+ "uglify-js": "^3.1.4"
+ }
+ },
"node_modules/lerna/node_modules/import-local": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz",
@@ -31852,6 +31874,16 @@
"node": ">=10"
}
},
+ "node_modules/lerna/node_modules/source-map": {
+ "version": "0.6.1",
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
+ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
+ "dev": true,
+ "license": "BSD-3-Clause",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
"node_modules/lerna/node_modules/tinyglobby": {
"version": "0.2.12",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.12.tgz",
@@ -47130,7 +47162,7 @@
"dayjs": "^1.11.23",
"dompurify": "^3.4.15",
"fetch-retry": "^6.0.0",
- "handlebars": "^4.7.9",
+ "handlebars": "^4.7.10",
"jed": "^1.1.1",
"lodash": "^4.18.1",
"lodash-es": "^4.18.1",
@@ -47505,7 +47537,7 @@
"@superset-ui/core": "*",
"ace-builds": "^1.4.14",
"dayjs": "^1.11.21",
- "handlebars": "^4.7.8",
+ "handlebars": "^4.7.10",
"lodash": "^4.18.1",
"react": "^18.3.0",
"react-ace": "^10.1.0",
@@ -47768,7 +47800,7 @@
"bootstrap-slider": "^11.0.2",
"d3-array": "^3.2.4",
"d3-scale": "^4.0.2",
- "handlebars": "^4.7.9",
+ "handlebars": "^4.7.10",
"lodash": "^4.18.1",
"lodash-es": "^4.18.1",
"maplibre-gl": "^6.8.0",
diff --git a/superset-frontend/package.json b/superset-frontend/package.json
index 549b7b59499..26ddfb000f7 100644
--- a/superset-frontend/package.json
+++ b/superset-frontend/package.json
@@ -364,7 +364,7 @@
"peerDependencies": {
"ace-builds": "^1.41.0",
"core-js": "^3.38.1",
- "handlebars": "^4.7.8",
+ "handlebars": "^4.7.10",
"react-ace": "^10.1.0",
"regenerator-runtime": "^0.14.1"
},
diff --git a/superset-frontend/packages/superset-ui-core/package.json b/superset-frontend/packages/superset-ui-core/package.json
index fe62792c633..b95a8fa826c 100644
--- a/superset-frontend/packages/superset-ui-core/package.json
+++ b/superset-frontend/packages/superset-ui-core/package.json
@@ -71,7 +71,7 @@
"dayjs": "^1.11.23",
"dompurify": "^3.4.15",
"fetch-retry": "^6.0.0",
- "handlebars": "^4.7.9",
+ "handlebars": "^4.7.10",
"jed": "^1.1.1",
"lodash": "^4.18.1",
"lodash-es": "^4.18.1",
diff --git a/superset-frontend/plugins/plugin-chart-handlebars/package.json b/superset-frontend/plugins/plugin-chart-handlebars/package.json
index c27756fc969..6a0dac2ef20 100644
--- a/superset-frontend/plugins/plugin-chart-handlebars/package.json
+++ b/superset-frontend/plugins/plugin-chart-handlebars/package.json
@@ -43,7 +43,7 @@
"@superset-ui/core": "*",
"ace-builds": "^1.4.14",
"dayjs": "^1.11.21",
- "handlebars": "^4.7.8",
+ "handlebars": "^4.7.10",
"lodash": "^4.18.1",
"react": "^18.3.0",
"react-ace": "^10.1.0",
diff --git a/superset-frontend/plugins/preset-chart-deckgl/package.json b/superset-frontend/plugins/preset-chart-deckgl/package.json
index 9864fe131c2..f36edbceef3 100644
--- a/superset-frontend/plugins/preset-chart-deckgl/package.json
+++ b/superset-frontend/plugins/preset-chart-deckgl/package.json
@@ -46,7 +46,7 @@
"bootstrap-slider": "^11.0.2",
"d3-array": "^3.2.4",
"d3-scale": "^4.0.2",
- "handlebars": "^4.7.9",
+ "handlebars": "^4.7.10",
"lodash": "^4.18.1",
"lodash-es": "^4.18.1",
"maplibre-gl": "^6.8.0",
(superset) 02/05: fix(bigquery): filter __NULL__ and __UNPARTITIONED__ from max partition query (#44156)
Posted by vi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
villebro pushed a commit to branch 7.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 4035ed96ae0f43b552b348d5843532dbd0a13c0e
Author: Konstantin Khlopkov <47...@users.noreply.github.com>
AuthorDate: Sun Oct 11 19:55:04 2026 +0300
fix(bigquery): filter __NULL__ and __UNPARTITIONED__ from max partition query (#44156)
Signed-off-by: Konstantin Khlopkov <ko...@gmail.com>
(cherry picked from commit 0e50b64263f574464eafcd8211a423a09ef919b5)
---
superset/db_engine_specs/bigquery.py | 20 ++++--
tests/unit_tests/db_engine_specs/test_bigquery.py | 86 ++++++++++++++++++++++-
2 files changed, 99 insertions(+), 7 deletions(-)
diff --git a/superset/db_engine_specs/bigquery.py b/superset/db_engine_specs/bigquery.py
index 1fac3223a50..d01c5ec606f 100644
--- a/superset/db_engine_specs/bigquery.py
+++ b/superset/db_engine_specs/bigquery.py
@@ -551,9 +551,11 @@ class BigQueryEngineSpec(BaseEngineSpec): # pylint: disable=too-many-public-met
) -> Select | None:
if partition_column := cls.get_time_partition_column(database, table):
max_partition_id = cls.get_max_partition_id(database, table)
- query = query.where(
- column(partition_column) == func.PARSE_DATE("%Y%m%d", max_partition_id)
- )
+ if max_partition_id is not None:
+ query = query.where(
+ column(partition_column)
+ == func.PARSE_DATE("%Y%m%d", max_partition_id)
+ )
return query
@@ -580,9 +582,15 @@ class BigQueryEngineSpec(BaseEngineSpec): # pylint: disable=too-many-public-met
)
# Build the query
- query = select(
- func.max(partitions_table.c.partition_id).label("max_partition_id")
- ).where(partitions_table.c.table_name == table.table)
+ query = (
+ select(func.max(partitions_table.c.partition_id).label("max_partition_id"))
+ .where(partitions_table.c.table_name == table.table)
+ .where(
+ partitions_table.c.partition_id.notin_(
+ ["__NULL__", "__UNPARTITIONED__"]
+ )
+ )
+ )
# Compile to BigQuery SQL
compiled_query = query.compile(
diff --git a/tests/unit_tests/db_engine_specs/test_bigquery.py b/tests/unit_tests/db_engine_specs/test_bigquery.py
index a35eaa0a893..81f3b168f2a 100644
--- a/tests/unit_tests/db_engine_specs/test_bigquery.py
+++ b/tests/unit_tests/db_engine_specs/test_bigquery.py
@@ -23,7 +23,7 @@ from unittest import mock
import pytest
from pytest_mock import MockerFixture
-from sqlalchemy import select
+from sqlalchemy import column, select
from sqlalchemy.engine.url import make_url
from sqlalchemy.sql import sqltypes
from sqlalchemy_bigquery import BigQueryDialect
@@ -1134,3 +1134,87 @@ def test_identifier_quote_uses_backticks() -> None:
"end": "`",
"escape_by_doubling": False,
}
+
+
+def test_where_latest_partition_filters_null_partitions(
+ mocker: MockerFixture,
+) -> None:
+ """
+ Test that get_max_partition_id excludes __NULL__ and __UNPARTITIONED__.
+
+ When a table has NULL values in the partitioning column, BigQuery creates a
+ partition named __NULL__. If no explicit WHERE filter is applied during
+ the initial scan, BigQuery may also report an __UNPARTITIONED__ partition.
+ Both of these special IDs sort lexicographically higher than numeric
+ YYYYMMDD strings and would otherwise become max(partition_id), causing
+ PARSE_DATE('%Y%m%d', '__NULL__') to fail.
+ """
+ from superset.db_engine_specs.bigquery import BigQueryEngineSpec
+
+ database = mock.MagicMock()
+ engine = mock.MagicMock()
+ engine_ctx = mock.MagicMock()
+ engine_ctx.__enter__.return_value = engine
+ mocker.patch.object(BigQueryEngineSpec, "get_engine", return_value=engine_ctx)
+
+ # Mock the partition metadata query: __NULL__ partitions are filtered out
+ cursor_mock = mock.MagicMock()
+ cursor_mock.fetchone.return_value = ("20251231",)
+ raw_conn_mock = mock.MagicMock()
+ raw_conn_mock.cursor.return_value = cursor_mock
+ database.get_raw_connection.return_value.__enter__.return_value = raw_conn_mock
+ database.get_dialect.return_value = BigQueryDialect()
+
+ # Mock time_partitioning to identify the partition column
+ client = mocker.patch.object(BigQueryEngineSpec, "_get_client").return_value
+ bq_table_mock = mock.MagicMock()
+ bq_table_mock.time_partitioning.field = "partition_date"
+ client.get_table.return_value = bq_table_mock
+
+ table = Table("test_table", "test_dataset", "test_project")
+
+ # Ensure the generated SQL filters out __NULL__ and __UNPARTITIONED__
+ max_partition = BigQueryEngineSpec.get_max_partition_id(database, table)
+ assert max_partition == "20251231"
+
+ # The returned SQL should be the result of filtering, not one of the special IDs
+ executed_sql = cursor_mock.execute.call_args[0][0]
+ assert "__NULL__" in executed_sql or "NOT IN" in executed_sql
+ assert "__UNPARTITIONED__" in executed_sql or "NOT IN" in executed_sql
+
+
+def test_where_latest_partition_skips_where_clause_when_max_is_none(
+ mocker: MockerFixture,
+) -> None:
+ """
+ Test that where_latest_partition leaves the query untouched when the table
+ has only reserved partitions and get_max_partition_id returns None.
+
+ Without the guard, the filter would compile to
+ PARSE_DATE('%Y%m%d', None), which fails at query time.
+ """
+ from superset.db_engine_specs.bigquery import BigQueryEngineSpec
+
+ database = mock.MagicMock()
+
+ # All partitions are reserved, so the aggregate returns NULL
+ cursor_mock = mock.MagicMock()
+ cursor_mock.fetchone.return_value = (None,)
+ raw_conn_mock = mock.MagicMock()
+ raw_conn_mock.cursor.return_value = cursor_mock
+ database.get_raw_connection.return_value.__enter__.return_value = raw_conn_mock
+ database.get_dialect.return_value = BigQueryDialect()
+
+ client = mocker.patch.object(BigQueryEngineSpec, "_get_client").return_value
+ bq_table_mock = mock.MagicMock()
+ bq_table_mock.time_partitioning.field = "partition_date"
+ client.get_table.return_value = bq_table_mock
+
+ table = Table("test_table", "test_dataset", "test_project")
+ query = select(column("foo"))
+
+ filtered = BigQueryEngineSpec.where_latest_partition(database, table, query)
+
+ # No WHERE clause was appended: the query is returned unchanged
+ assert filtered is query
+ assert not query.whereclause
(superset) 03/05: fix(histogram): normalize before accumulating a cumulative histogram (#44652)
Posted by vi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
villebro pushed a commit to branch 7.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit ee6bb3ab198b06a455377022da9f080c4fca6ad4
Author: Suliman Abdulrazzaq <14...@users.noreply.github.com>
AuthorDate: Sun Oct 11 20:20:36 2026 +0300
fix(histogram): normalize before accumulating a cumulative histogram (#44652)
(cherry picked from commit 2c8665f9cbcb440e93cef110750c5839d3aa4ea8)
---
superset/utils/pandas_postprocessing/histogram.py | 8 ++++--
.../pandas_postprocessing/test_histogram.py | 32 ++++++++++------------
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/superset/utils/pandas_postprocessing/histogram.py b/superset/utils/pandas_postprocessing/histogram.py
index 28375207ae6..25d389d6952 100644
--- a/superset/utils/pandas_postprocessing/histogram.py
+++ b/superset/utils/pandas_postprocessing/histogram.py
@@ -91,8 +91,7 @@ def histogram(
def hist_values(series: Series) -> np.ndarray:
# we might have NaN values as the result of grouping so we need to drop them
- result = np.histogram(series.dropna(), bins=bin_edges)[0]
- return result if not cumulative else np.cumsum(result)
+ return np.histogram(series.dropna(), bins=bin_edges)[0]
if len(groupby) == 0:
# without grouping
@@ -107,9 +106,14 @@ def histogram(
)
histogram_df.columns = bin_edges_str
+ # normalize by the total count of data points before accumulating, so that a
+ # cumulative histogram shows the share of data points up to each bin
if normalize:
histogram_df = histogram_df / histogram_df.values.sum()
+ if cumulative:
+ histogram_df = histogram_df.cumsum(axis=1)
+
# reorder the columns to have the groupby columns first
histogram_df = histogram_df.reset_index().loc[:, groupby + bin_edges_str]
diff --git a/tests/unit_tests/pandas_postprocessing/test_histogram.py b/tests/unit_tests/pandas_postprocessing/test_histogram.py
index bfc702a71bb..474c412f032 100644
--- a/tests/unit_tests/pandas_postprocessing/test_histogram.py
+++ b/tests/unit_tests/pandas_postprocessing/test_histogram.py
@@ -103,24 +103,20 @@ def test_histogram_with_groupby_and_cumulative_and_normalize():
"6.4 - 8.2",
"8.2 - 10.0",
]
- assert result.values.tolist() == [
- [
- "A",
- 0.06666666666666667,
- 0.06666666666666667,
- 0.13333333333333333,
- 0.13333333333333333,
- 0.2,
- ],
- [
- "B",
- 0.0,
- 0.06666666666666667,
- 0.06666666666666667,
- 0.13333333333333333,
- 0.13333333333333333,
- ],
- ]
+ # each bin holds the share of all data points that are in the group and up to
+ # that bin
+ assert result["group"].tolist() == ["A", "B"]
+ assert result.iloc[0, 1:].tolist() == pytest.approx([0.2, 0.2, 0.4, 0.4, 0.6])
+ assert result.iloc[1, 1:].tolist() == pytest.approx([0.0, 0.2, 0.2, 0.4, 0.4])
+
+
+def test_histogram_cumulative_and_normalize_ends_at_one():
+ data_with_no_groupings = DataFrame({"a": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]})
+ result = histogram(
+ data_with_no_groupings, "a", [], bins, cumulative=True, normalize=True
+ )
+ assert result.shape == (1, bins)
+ assert result.values.tolist()[0] == pytest.approx([0.2, 0.4, 0.6, 0.8, 1.0])
def test_histogram_with_non_numeric_column():
(superset) 04/05: fix(databricks): enable equality operators for boolean filters (#36765) (#44355)
Posted by vi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
villebro pushed a commit to branch 7.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 1f58f34e90d5a100fce4b11e57f074b05d4bd1ea
Author: Francesco.Castaldi <in...@francescocastaldi.it>
AuthorDate: Sun Oct 11 23:34:16 2026 +0200
fix(databricks): enable equality operators for boolean filters (#36765) (#44355)
Co-authored-by: Francesco Castaldi <fr...@mapsgroup.it>
(cherry picked from commit 90dc7ac32899b50ac60ea0ec7489ae5a3059d43c)
---
superset/db_engine_specs/base.py | 19 +++
superset/db_engine_specs/databricks.py | 37 +++++-
superset/db_engine_specs/spark.py | 18 +++
superset/models/helpers.py | 5 +-
.../unit_tests/db_engine_specs/test_databricks.py | 133 ++++++++++++++++++++-
tests/unit_tests/models/helpers_test.py | 42 +++++++
6 files changed, 251 insertions(+), 3 deletions(-)
diff --git a/superset/db_engine_specs/base.py b/superset/db_engine_specs/base.py
index f1375edecd2..d2b5fa07eb1 100644
--- a/superset/db_engine_specs/base.py
+++ b/superset/db_engine_specs/base.py
@@ -1863,6 +1863,24 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
"""
return None
+ @classmethod
+ def coerce_boolean_for_sql(cls, value: bool | None) -> Any:
+ """
+ Convert a Python boolean to the value used when building SQL filter
+ expressions for boolean columns.
+
+ Most engines accept Python booleans, but some drivers render them as
+ integer literals (0/1), which strict engines like Databricks reject
+ with a DATATYPE_MISMATCH error when the value is compared against a
+ boolean column (#36765). Override this in engine specs whose drivers
+ misrender Python booleans, returning an expression that compiles to an
+ explicit boolean literal (e.g. sqlalchemy.true()/false()).
+
+ :param value: Boolean value (True, False, or None)
+ :return: Value suitable for the engine's filter expressions
+ """
+ return value
+
@classmethod
def handle_boolean_filter(
cls, sqla_col: Any, op: str, value: bool
@@ -1879,6 +1897,7 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
:param value: Boolean value (True or False)
:return: SQLAlchemy expression for the boolean filter
"""
+ value = cls.coerce_boolean_for_sql(value)
if cls.use_equality_for_boolean_filters:
return sqla_col == value
else:
diff --git a/superset/db_engine_specs/databricks.py b/superset/db_engine_specs/databricks.py
index c108b911ce0..ae2f0436d17 100644
--- a/superset/db_engine_specs/databricks.py
+++ b/superset/db_engine_specs/databricks.py
@@ -28,7 +28,7 @@ from flask import g
from flask_babel import gettext as __
from marshmallow import fields, Schema
from marshmallow.validate import Range
-from sqlalchemy import text, types
+from sqlalchemy import false, text, true, types
from sqlalchemy.engine.default import DefaultDialect
from sqlalchemy.engine.reflection import Inspector
from sqlalchemy.engine.url import URL
@@ -251,6 +251,8 @@ time_grain_expressions: dict[str | None, str] = {
class DatabricksBaseEngineSpec(BaseEngineSpec):
+ """Base engine specification for Databricks flavors and connection methods."""
+
_time_grain_expressions = time_grain_expressions
# Databricks SQL is Spark SQL under the hood: identifiers are quoted with
@@ -258,6 +260,27 @@ class DatabricksBaseEngineSpec(BaseEngineSpec):
identifier_quote_start: str = "`"
identifier_quote_end: str = "`"
+ # Databricks SQL applies strict type checking: comparing a boolean column
+ # against an integer literal (or a bound Python boolean that the
+ # Hive/Databricks driver renders as 0/1) fails with
+ # DATATYPE_MISMATCH.DATA_DIFF_TYPES (see #36765). Enabling equality
+ # operators ensures boolean filters compile as 'col = true' / 'col = false'.
+ use_equality_for_boolean_filters: bool = True
+
+ @classmethod
+ def coerce_boolean_for_sql(cls, value: bool | None) -> Any:
+ """
+ Render Python booleans as explicit boolean keywords.
+
+ The Hive/Databricks SQLAlchemy dialects render Python booleans as
+ integer literals (0/1) in some binding paths, so emit sqlalchemy
+ true()/false() instead: they always compile to the TRUE/FALSE keywords
+ and never reach the driver as bind parameters (#36765).
+ """
+ if value is None:
+ return None
+ return true() if value else false()
+
@classmethod
def convert_dttm(
cls, target_type: str, dttm: datetime, db_extra: dict[str, Any] | None = None
@@ -1109,6 +1132,18 @@ class DatabricksHiveEngineSpec(HiveEngineSpec):
# consolidates all Databricks connection methods. This spec exists for
# backwards compatibility with Interactive Cluster connections.
+ # Databricks Interactive Clusters apply the same strict type checking as
+ # Databricks SQL, so boolean filters need equality against boolean keywords.
+ use_equality_for_boolean_filters: bool = True
+
+ @classmethod
+ def coerce_boolean_for_sql(cls, value: bool | None) -> Any:
+ # Same rationale as DatabricksBaseEngineSpec: the Hive driver renders
+ # Python booleans as 0/1 in some binding paths (#36765).
+ if value is None:
+ return None
+ return true() if value else false()
+
_show_functions_column = "function"
_time_grain_expressions = time_grain_expressions
diff --git a/superset/db_engine_specs/spark.py b/superset/db_engine_specs/spark.py
index 5c5360a718d..1fa46b359c5 100644
--- a/superset/db_engine_specs/spark.py
+++ b/superset/db_engine_specs/spark.py
@@ -16,6 +16,9 @@
# under the License.
from __future__ import annotations
+from typing import Any
+
+from sqlalchemy import false, true
from sqlalchemy.dialects import registry
from superset.constants import TimeGrain
@@ -42,11 +45,26 @@ time_grain_expressions: dict[str | None, str] = {
class SparkEngineSpec(HiveEngineSpec):
+ """Engine specification for Apache Spark SQL."""
+
engine = "spark"
registry.register("spark", "pyhive.sqlalchemy_hive", "HiveDialect")
_time_grain_expressions = time_grain_expressions
engine_name = "Apache Spark SQL"
+ # Spark SQL shares syntax rules with Databricks SQL; equality comparisons
+ # are required for boolean filters to avoid type mismatch errors (see #36765).
+ use_equality_for_boolean_filters: bool = True
+
+ @classmethod
+ def coerce_boolean_for_sql(cls, value: bool | None) -> Any:
+ # The pyhive driver renders Python booleans as 0/1 in some binding
+ # paths, and Spark SQL applies the same strict type checking as
+ # Databricks SQL (#36765).
+ if value is None:
+ return None
+ return true() if value else false()
+
metadata = {
"description": "Apache Spark SQL is a module for structured data processing.",
"logo": "apache-spark.png",
diff --git a/superset/models/helpers.py b/superset/models/helpers.py
index 50be2be0dce..f5e06be6d4a 100644
--- a/superset/models/helpers.py
+++ b/superset/models/helpers.py
@@ -4067,7 +4067,10 @@ class ExploreMixin: # pylint: disable=too-many-public-methods
elif value is not None:
value = handle_temporal_value(value)
if target_generic_type == utils.GenericDataType.BOOLEAN:
- return utils.cast_to_boolean(value)
+ boolean_value = utils.cast_to_boolean(value)
+ if db_engine_spec is not None:
+ return db_engine_spec.coerce_boolean_for_sql(boolean_value)
+ return boolean_value
return value
if isinstance(values, (list, tuple)):
diff --git a/tests/unit_tests/db_engine_specs/test_databricks.py b/tests/unit_tests/db_engine_specs/test_databricks.py
index fb06011bf8f..4614f0a10d0 100644
--- a/tests/unit_tests/db_engine_specs/test_databricks.py
+++ b/tests/unit_tests/db_engine_specs/test_databricks.py
@@ -26,18 +26,30 @@ from urllib.parse import parse_qs, urlparse
import pytest
from packaging.requirements import Requirement
from pytest_mock import MockerFixture
-from sqlalchemy import __version__ as sqlalchemy_version, create_engine, text
+from sqlalchemy import (
+ __version__ as sqlalchemy_version,
+ Boolean,
+ Column,
+ create_engine,
+ literal_column,
+ text,
+)
from sqlalchemy.engine.url import make_url
+from sqlalchemy.sql.elements import ColumnElement
from superset.db_engine_specs.base import BaseEngineSpec, OAuth2State
from superset.db_engine_specs.databricks import (
+ DatabricksBaseEngineSpec,
+ DatabricksHiveEngineSpec,
DatabricksNativeEngineSpec,
DatabricksPythonConnectorEngineSpec,
)
+from superset.db_engine_specs.spark import SparkEngineSpec
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
from superset.exceptions import OAuth2Error, OAuth2RedirectError
from superset.superset_typing import OAuth2ClientConfig
from superset.utils import json
+from superset.utils.core import FilterOperator
from superset.utils.oauth2 import decode_oauth2_state
from tests.unit_tests.db_engine_specs.utils import assert_convert_dttm
from tests.unit_tests.fixtures.common import dttm # noqa: F401
@@ -1468,3 +1480,122 @@ def test_monkeypatch_dialect_preserves_hive_databricks_escaping(
)
== r"'O\'Hara'"
)
+
+
+def test_use_equality_for_boolean_filters_property() -> None:
+ """
+ Test that Databricks engine specs enable use_equality_for_boolean_filters.
+ Databricks SQL applies strict type checking: comparing a boolean column
+ against an integer or a driver-rendered boolean bind fails with
+ DATATYPE_MISMATCH (see #36765), so boolean filters use equality against
+ explicit boolean keywords.
+ """
+ assert DatabricksBaseEngineSpec.use_equality_for_boolean_filters is True
+ assert DatabricksNativeEngineSpec.use_equality_for_boolean_filters is True
+ assert DatabricksPythonConnectorEngineSpec.use_equality_for_boolean_filters is True
+ assert DatabricksHiveEngineSpec.use_equality_for_boolean_filters is True
+ assert SparkEngineSpec.use_equality_for_boolean_filters is True
+
+
+@pytest.mark.parametrize(
+ "engine_spec",
+ [
+ DatabricksBaseEngineSpec,
+ DatabricksNativeEngineSpec,
+ DatabricksPythonConnectorEngineSpec,
+ DatabricksHiveEngineSpec,
+ SparkEngineSpec,
+ ],
+ ids=[
+ "databricks_base",
+ "databricks_native",
+ "databricks_python_connector",
+ "databricks_hive",
+ "spark",
+ ],
+)
+def test_coerce_boolean_for_sql_emits_boolean_keywords(
+ engine_spec: type[BaseEngineSpec],
+) -> None:
+ """
+ Test that boolean filter values are coerced to SQLAlchemy true()/false()
+ expressions on every Databricks and Spark spec, so the compiled SQL always
+ contains the TRUE/FALSE keywords and the values never reach the driver as
+ bind parameters (which pyhive renders as 0/1, see #36765).
+ """
+ true_value = engine_spec.coerce_boolean_for_sql(True)
+ assert isinstance(true_value, ColumnElement)
+ assert str(true_value.compile(compile_kwargs={"literal_binds": True})) == "true"
+
+ false_value = engine_spec.coerce_boolean_for_sql(False)
+ assert isinstance(false_value, ColumnElement)
+ assert str(false_value.compile(compile_kwargs={"literal_binds": True})) == "false"
+
+ assert engine_spec.coerce_boolean_for_sql(None) is None
+
+
+@pytest.mark.parametrize(
+ "engine_spec",
+ [
+ DatabricksBaseEngineSpec,
+ DatabricksNativeEngineSpec,
+ DatabricksPythonConnectorEngineSpec,
+ DatabricksHiveEngineSpec,
+ SparkEngineSpec,
+ ],
+ ids=[
+ "databricks_base",
+ "databricks_native",
+ "databricks_python_connector",
+ "databricks_hive",
+ "spark",
+ ],
+)
+@pytest.mark.parametrize(
+ "filter_operator,expected",
+ [
+ (FilterOperator.IS_TRUE, "is_test_user = true"),
+ (FilterOperator.IS_FALSE, "is_test_user = false"),
+ ],
+)
+def test_handle_boolean_filter_compiles_boolean_keywords(
+ engine_spec: type[BaseEngineSpec],
+ filter_operator: FilterOperator,
+ expected: str,
+) -> None:
+ """
+ Test that handle_boolean_filter produces an equality comparison against an
+ explicit boolean keyword, with no bind parameters left for the driver to
+ render as integers.
+ """
+ bool_col = Column("is_test_user", Boolean)
+ result = engine_spec.handle_boolean_filter(
+ bool_col,
+ filter_operator,
+ filter_operator == FilterOperator.IS_TRUE,
+ )
+ compiled = result.compile()
+ assert str(compiled) == expected
+ assert compiled.params == {}
+
+
+def test_handle_boolean_filter_computed_column_compilation() -> None:
+ """
+ Test that handle_boolean_filter compiles properly on computed boolean
+ expressions.
+ """
+ computed_col = literal_column("(total_amount > 100)")
+ for engine_spec in (
+ DatabricksBaseEngineSpec,
+ DatabricksNativeEngineSpec,
+ DatabricksPythonConnectorEngineSpec,
+ DatabricksHiveEngineSpec,
+ SparkEngineSpec,
+ ):
+ result = engine_spec.handle_boolean_filter(
+ computed_col, FilterOperator.IS_TRUE, True
+ )
+ assert (
+ str(result.compile(compile_kwargs={"literal_binds": True}))
+ == "(total_amount > 100) = true"
+ )
diff --git a/tests/unit_tests/models/helpers_test.py b/tests/unit_tests/models/helpers_test.py
index 448746d894e..a3e8bc56b31 100644
--- a/tests/unit_tests/models/helpers_test.py
+++ b/tests/unit_tests/models/helpers_test.py
@@ -5132,6 +5132,48 @@ def test_temporal_epoch_string_filter_list_is_coerced_for_clickhouse() -> None:
assert str(values[0]) == "toDate('2026-04-27')"
+@pytest.mark.parametrize(
+ "operator",
+ [FilterOperator.IN, FilterOperator.NOT_IN],
+)
+@pytest.mark.parametrize(
+ "values",
+ [[0, 1], [False, True], ["false", "true"]],
+)
+def test_boolean_filter_values_coerced_for_databricks(
+ operator: FilterOperator,
+ values: list[Any],
+) -> None:
+ """
+ Native dashboard filters on boolean columns build `IN` clauses through
+ `filter_values_handler` (#36765). Databricks rejects `col IN (0)` with
+ DATATYPE_MISMATCH, and the Hive/Databricks drivers render bound Python
+ booleans as integers, so values must coerce to boolean keywords.
+ """
+ from sqlalchemy import Boolean, Column
+
+ from superset.db_engine_specs.databricks import DatabricksBaseEngineSpec
+ from superset.db_engine_specs.spark import SparkEngineSpec
+ from superset.models.helpers import ExploreMixin
+
+ for db_engine_spec in (DatabricksBaseEngineSpec, SparkEngineSpec):
+ coerced = ExploreMixin.filter_values_handler(
+ values=values,
+ operator=operator,
+ target_generic_type=GenericDataType.BOOLEAN,
+ is_list_target=True,
+ db_engine_spec=db_engine_spec,
+ )
+ assert isinstance(coerced, list)
+ assert len(coerced) == 2
+ assert all(isinstance(value, ColumnElement) for value in coerced)
+ # the coerced values compile to boolean keywords and never reach the
+ # driver as bind parameters (which pyhive renders as 0/1)
+ compiled = Column("is_test_user", Boolean).in_(coerced).compile()
+ assert str(compiled) == "is_test_user IN (false, true)"
+ assert compiled.params == {}
+
+
@pytest.mark.parametrize(
"target_type,expected",
[
(superset) 01/05: fix(column-config): allow commas in D3 number formats (#45145)
Posted by vi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
villebro pushed a commit to branch 7.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 733ad716c3e938f8eafc49f4b9ff5375fa379fa2
Author: Rabuma A. Bekele <ia...@gmail.com>
AuthorDate: Sat Oct 10 01:39:51 2026 +0200
fix(column-config): allow commas in D3 number formats (#45145)
(cherry picked from commit ab2c69f29cd0c47e91f73e51b0ff480c62f2b17b)
---
.../src/utils/D3Formatting.ts | 1 +
.../ColumnConfigConstants.test.tsx | 25 +++++++++++-----------
.../controls/ColumnConfigControl/constants.tsx | 2 ++
3 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/utils/D3Formatting.ts b/superset-frontend/packages/superset-ui-chart-controls/src/utils/D3Formatting.ts
index 2351cddc4ec..8a64e91ab4a 100644
--- a/superset-frontend/packages/superset-ui-chart-controls/src/utils/D3Formatting.ts
+++ b/superset-frontend/packages/superset-ui-chart-controls/src/utils/D3Formatting.ts
@@ -43,6 +43,7 @@ const d3Formatted: [string, string][] = [
'.2%',
'.3%',
'.4r',
+ ',.0f',
',.1f',
',.2f',
',.3f',
diff --git a/superset-frontend/src/explore/components/controls/ColumnConfigControl/ColumnConfigConstants.test.tsx b/superset-frontend/src/explore/components/controls/ColumnConfigControl/ColumnConfigConstants.test.tsx
index dc6407c812f..75b04431ca0 100644
--- a/superset-frontend/src/explore/components/controls/ColumnConfigControl/ColumnConfigConstants.test.tsx
+++ b/superset-frontend/src/explore/components/controls/ColumnConfigControl/ColumnConfigConstants.test.tsx
@@ -19,21 +19,22 @@
import { SHARED_COLUMN_CONFIG_PROPS } from './constants';
-test('should allow commas in D3 format inputs', () => {
+test('should include the comma-separated number format preset', () => {
const { options } = SHARED_COLUMN_CONFIG_PROPS.d3NumberFormat;
- const labels = (options ?? []).map((option: { label: unknown }) =>
- String(option.label),
- );
- expect(labels.some((label: string) => label.includes(','))).toBe(true);
+
+ expect(options).toContainEqual({
+ value: ',.0f',
+ label: ',.0f (12345.432 => 12,345)',
+ });
});
-test('should use defaults from Select token separators', () => {
- expect(
- Object.prototype.hasOwnProperty.call(
- SHARED_COLUMN_CONFIG_PROPS.d3NumberFormat,
- 'tokenSeparators',
- ),
- ).toBe(false);
+test('should not treat commas as D3 format token separators', () => {
+ expect(SHARED_COLUMN_CONFIG_PROPS.d3NumberFormat.tokenSeparators).toEqual([
+ '\r\n',
+ '\n',
+ '\t',
+ ';',
+ ]);
});
test('d3NumberFormat and d3TimeFormat should allow free-text entry', () => {
diff --git a/superset-frontend/src/explore/components/controls/ColumnConfigControl/constants.tsx b/superset-frontend/src/explore/components/controls/ColumnConfigControl/constants.tsx
index 71f860b6c06..0b09ddd60aa 100644
--- a/superset-frontend/src/explore/components/controls/ColumnConfigControl/constants.tsx
+++ b/superset-frontend/src/explore/components/controls/ColumnConfigControl/constants.tsx
@@ -56,6 +56,8 @@ const d3NumberFormat: ControlFormItemSpec<'Select'> = {
})),
defaultValue: D3_FORMAT_OPTIONS[0][0],
creatable: true,
+ // Keep commas out of token separators because they are valid in D3 number formats.
+ tokenSeparators: ['\r\n', '\n', '\t', ';'],
minWidth: '14em',
debounceDelay: 500,
};