You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/08/29 03:37:27 UTC
(superset) branch master updated: fix(table-chart): support where for adhoc columns with server-side pagination (#42706)
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new de33efae983 fix(table-chart): support where for adhoc columns with server-side pagination (#42706)
de33efae983 is described below
commit de33efae983a874d4af007016f2f7ded03449fe0
Author: Mallikarjuna Reddy Nimmakayala <ma...@gmail.com>
AuthorDate: Sat Aug 29 09:07:20 2026 +0530
fix(table-chart): support where for adhoc columns with server-side pagination (#42706)
---
.../plugins/plugin-chart-table/src/TableChart.tsx | 5 +-
superset/models/helpers.py | 12 +++++
tests/unit_tests/models/helpers_test.py | 53 ++++++++++++++++++++++
3 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
index 6c22aa29418..81ba43f1c43 100644
--- a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
+++ b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
@@ -462,13 +462,14 @@ export default function TableChart<D extends DataRecord = DataRecord>(
// only take relevant page size options
const pageSizeOptions = useMemo(() => {
- const getServerPagination = (n: number) => n <= rowCount;
+ const getServerPagination = (n: number) =>
+ n <= Math.max(rowCount, serverPageLength);
return (
serverPagination ? SERVER_PAGE_SIZE_OPTIONS : PAGE_SIZE_OPTIONS
).filter(([n]) =>
serverPagination ? getServerPagination(n) : n <= 2 * data.length,
) as SizeOption[];
- }, [data.length, rowCount, serverPagination]);
+ }, [data.length, rowCount, serverPageLength, serverPagination]);
const getValueRange = useCallback(
function getValueRange(key: string, alignPositiveNegative: boolean) {
diff --git a/superset/models/helpers.py b/superset/models/helpers.py
index 98b97ed96ce..191cc673e7b 100644
--- a/superset/models/helpers.py
+++ b/superset/models/helpers.py
@@ -4823,6 +4823,18 @@ class ExploreMixin: # pylint: disable=too-many-public-methods
template_processor=template_processor
)
is_metric_filter = True
+ elif (
+ col_obj is None
+ and isinstance(flt_col, str)
+ and flt_col in adhoc_columns_by_label
+ ):
+ sqla_col, _unused = self.adhoc_column_to_sqla(
+ col=adhoc_columns_by_label[flt_col],
+ template_processor=template_processor,
+ )
+ if isinstance(sqla_col, ColumnElement):
+ applied_adhoc_filters_columns.append(flt_col)
+
filter_grain = flt.get("grain")
# Check if this filter should be skipped because it was handled in
diff --git a/tests/unit_tests/models/helpers_test.py b/tests/unit_tests/models/helpers_test.py
index 47f97f0239c..d1b000ae452 100644
--- a/tests/unit_tests/models/helpers_test.py
+++ b/tests/unit_tests/models/helpers_test.py
@@ -5054,3 +5054,56 @@ def test_adhoc_type_probe_does_not_get_sampling_retry(
table.adhoc_column_to_sqla(adhoc_col)
retry.assert_not_called()
+
+
+def test_filter_adhoc_column(database: Database) -> None:
+ """
+ Test that filter works with adhoc column labels.
+ When filter contains a string that matches the label of an adhoc column
+ in the columns list, it should correctly convert to a SQLAlchemy column
+ instead of raising QueryObjectValidationError.
+ """
+ from superset.connectors.sqla.models import SqlaTable, TableColumn
+
+ table = SqlaTable(
+ table_name="test_table",
+ database=database,
+ columns=[
+ TableColumn(column_name="name", type="TEXT"),
+ TableColumn(column_name="real_name", type="TEXT"),
+ ],
+ )
+
+ # Should not raise QueryObjectValidationError
+ result = table.get_sqla_query(
+ columns=[
+ "name",
+ {
+ "expressionType": "SQL",
+ "label": "full_name",
+ "sqlExpression": "real_name",
+ },
+ ],
+ orderby=[],
+ metrics=[],
+ extras={},
+ filter=[
+ {"col": "full_name", "op": "ILIKE", "val": "Zona%"}
+ ], # Filter by adhoc column label
+ granularity=None,
+ is_timeseries=False,
+ )
+ assert result is not None
+
+ # Verify the WHERE predicate uses the resolved adhoc expression and value.
+ with database.get_sqla_engine() as engine:
+ sql = str(
+ result.sqla_query.compile(
+ dialect=engine.dialect,
+ compile_kwargs={"literal_binds": True},
+ )
+ )
+
+ assert "real_name AS full_name" in sql
+ assert "WHERE" in sql
+ assert "lower(real_name) LIKE lower('Zona%')" in sql