Comments (3)
The issue you're experiencing with the "Drill to details by" feature not applying filters correctly in Apache Superset version 4.0.1 is recognized and has been addressed in a subsequent update. Specifically, a fix related to enabling the DrillBy feature in charts without filters (dimensions) might also resolve issues related to filter application in drill-down SQL query generation. This fix is documented in the pull request #27941.
The "Drill to details by" feature's behavior, including how it handles filters in SQL query generation, is influenced by several factors, including chart configurations, user permissions, and the specific version of Superset you're using. Known limitations in version 4.0.1, such as database support, aggregations, filters requirement, and chart type support, could also contribute to the problem.
To address this issue, ensure you're running a version of Superset that includes the fix mentioned above. If the problem persists even after updating, it may be worth reviewing the specific configurations and settings related to the "Drill to details by" feature in your Superset installation, including chart type support and filter handling.
If you need further assistance or have additional questions, feel free to ask.
Details
Sources
- CHANGELOG/4.0.1.md
- superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.tsx
- superset/common/query_actions.py
- superset-frontend/src/components/Chart/ChartContextMenu/ChartContextMenu.tsx
- superset/models/helpers.py
- superset-frontend/packages/superset-ui-core/src/query/processFilters.ts
- superset-frontend/packages/superset-ui-core/test/query/processFilters.test.ts
- superset-frontend/cypress-base/cypress/e2e/dashboard/drilltodetail.test.ts
- superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.test.tsx
- superset-frontend/cypress-base/cypress/e2e/dashboard/drillby.test.ts
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
To continue the conversation, mention @dosu.
from superset.
To resolve the issue where the "Drill to details by" feature in Apache Superset version 4.0.1 ignores applied filters, ensure that filters are correctly passed and applied both in the frontend and backend.
Frontend Changes
-
Pass Filters to
DrillDetailMenuItems
Component:
Ensure thefilters
object contains the correct filter values and is passed to theDrillDetailMenuItems
component.if (showDrillToDetail) { menuItems.push( <DrillDetailMenuItems chartId={id} formData={formData} filters={filters?.drillToDetail} isContextMenu contextMenuY={clientY} onSelection={onSelection} submenuIndex={showCrossFilters ? 2 : 1} showModal={drillModalIsOpen} setShowModal={setDrillModalIsOpen} {...(additionalConfig?.drillToDetail || {})} />, ); }
-
Verify
handleContextMenu
Function:
Ensure thehandleContextMenu
function constructs thedrillToDetailFilters
based on the selected filters.const handleContextMenu = useCallback( ( e: MouseEvent, colKey: (string | number | boolean)[] | undefined, rowKey: (string | number | boolean)[] | undefined, dataPoint: { [key: string]: string }, ) => { if (onContextMenu) { e.preventDefault(); e.stopPropagation(); const drillToDetailFilters: BinaryQueryObjectFilterClause[] = []; if (colKey && colKey.length > 1) { colKey.forEach((val, i) => { const col = cols[i]; const formatter = dateFormatters[col]; const formattedVal = formatter?.(val as number) || String(val); if (i > 0) { drillToDetailFilters.push({ col, op: '==', val, formattedVal, grain: formatter ? timeGrainSqla : undefined, }); } }); } if (rowKey) { rowKey.forEach((val, i) => { const col = rows[i]; const formatter = dateFormatters[col]; const formattedVal = formatter?.(val as number) || String(val); drillToDetailFilters.push({ col, op: '==', val, formattedVal, grain: formatter ? timeGrainSqla : undefined, }); }); } onContextMenu(e.clientX, e.clientY, { drillToDetail: drillToDetailFilters, crossFilter: getCrossFilterDataMask(dataPoint), drillBy: dataPoint && { filters: [ { col: Object.keys(dataPoint)[0], op: '==', val: Object.values(dataPoint)[0], }, ], groupbyFieldName: rowKey ? 'groupbyRows' : 'groupbyColumns', }, }); } }, [ cols, dateFormatters, getCrossFilterDataMask, onContextMenu, rows, timeGrainSqla, ], );
Backend Changes
-
Apply Filters in
_get_drill_detail
Function:
Ensure the_get_drill_detail
function insuperset/common/query_actions.py
correctly applies the filters to the query object.def _get_drill_detail( query_context: QueryContext, query_obj: QueryObject, force_cached: bool = False ) -> dict[str, Any]: datasource = _get_datasource(query_context, query_obj) query_obj = copy.copy(query_obj) query_obj.is_timeseries = False query_obj.orderby = [] query_obj.metrics = None query_obj.post_processing = [] qry_obj_cols = [] for o in datasource.columns: if isinstance(o, dict): qry_obj_cols.append(o.get("column_name")) else: qry_obj_cols.append(o.column_name) query_obj.columns = qry_obj_cols return _get_full(query_context, query_obj, force_cached)
-
Check
QueryContext
Object:
Ensure theQueryContext
object handles filters correctly when generating SQL queries for drill-down details.def _apply_filters(self, query_object: QueryObject) -> None: if query_object.time_range: for filter_object in query_object.filter: if filter_object["op"] == "TEMPORAL_RANGE": filter_object["val"] = query_object.time_range
-
Verify
buildQuery
Function:
Ensure thebuildQuery
function insuperset-frontend/src/filters/components/Select/buildQuery.ts
correctly adds extra filters based on user input.const buildQuery: BuildQuery<PluginFilterSelectQueryFormData> = ( formData: PluginFilterSelectQueryFormData, options, ) => { const { search, coltypeMap } = options?.ownState || {}; const { sortAscending, sortMetric } = { ...DEFAULT_FORM_DATA, ...formData }; return buildQueryContext(formData, baseQueryObject => { const { columns = [], filters = [] } = baseQueryObject; const extraFilters: QueryObjectFilterClause[] = []; if (search) { columns.filter(isPhysicalColumn).forEach(column => { const label = getColumnLabel(column); if ( coltypeMap[label] === GenericDataType.String || (coltypeMap[label] === GenericDataType.Numeric && !Number.isNaN(Number(search))) ) { extraFilters.push({ col: column, op: 'ILIKE', val: `%${search}%`, }); } }); } const sortColumns = sortMetric ? [sortMetric] : columns; const query: QueryObject[] = [ { ...baseQueryObject, columns, metrics: sortMetric ? [sortMetric] : [], filters: filters.concat(extraFilters), orderby: sortMetric || sortAscending !== undefined ? sortColumns.map(column => [column, !!sortAscending]) : [], }, ]; return query; }); };
By ensuring that filters are correctly passed and applied at each step, you should be able to resolve the issue where the "Drill to details by" feature ignores the applied filters.
Details
Sources
- Drill by function error with caching enabled
- superset-frontend/src/components/Chart/ChartContextMenu/ChartContextMenu.tsx
- superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx
- superset/common/query_actions.py
- superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.tsx
- superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.test.tsx
- superset/common/query_context_factory.py
- superset/common/query_context.py
- superset-frontend/src/filters/components/Select/buildQuery.ts
- tests/integration_tests/query_context_tests.py
- superset-frontend/src/filters/components/TimeColumn/buildQuery.ts
- superset-frontend/cypress-base/cypress/e2e/dashboard/drilltodetail.test.ts
- superset-frontend/cypress-base/cypress/e2e/dashboard/drillby.test.ts
- superset/common/query_context_processor.py
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
To continue the conversation, mention @dosu.
from superset.
Hi ,
This is not related to the #27941 (i've checked the problem statement of this fix)
from superset.
Related Issues (20)
- superset 4.0.1 uses werkzeug 3.0.1 with CVE => should update to 3.0.3 or newer HOT 2
- superset 4.0.1 uses sqlparse 0.4.4 with two high CVE findings => update to 0.5.0 HOT 2
- Doris made an error in creating a chart using the GROUP_CONCAT syntax HOT 2
- Content not from webpack is served from 'D:\tech_release\superset-fork\superset\static\assets' directory HOT 4
- 🐛 RLS form not showing all datasets available HOT 1
- requests.exceptions.HTTPError: 422 Client Error: UNPROCESSABLE ENTITY for url: HOT 1
- ROW_LIMIT not working HOT 5
- Superset throws access is denied error when viewing dashboard even after signing in. HOT 2
- {{ current_user_email() }} doesn't work HOT 3
- [SIP-136] split alert and report Menu and Access rights HOT 4
- (empty post) HOT 1
- Broken ssh connections: Could not establish session to SSH gateway HOT 2
- BUG) Superset get wrong value of TIMESTAMP WITH TIME ZONE type field on Trino client HOT 2
- Can't get ALERTS & REPORTS working. Error: Failed taking a screenshot Message: 'geckodriver' executable needs to be in PATH. HOT 4
- Superset throws unexpected error while loading filters in a dashboard. HOT 1
- Can't export dashboards with CLI if 'admin' user is not created HOT 1
- Option for file could be the same for superset export-dashboards / superset import-dashboards
- superset fab list-users return username, email, role but not firstname, lastname, active HOT 6
- Can't import dashbaords with CLI HOT 6
- 🐛 Problems creating rows and columns in the superset. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from superset.