Skip to content

"Drill to Details by" Feature Ignores Applied Filters in Superset 4.0.1 #28562

Open
@aamir4813

Description

@aamir4813

Bug description

In Superset, the "Drill to details by" feature does not apply filters correctly when generating the SQL query. If used without any filters, all raw data is displayed correctly. However, when filters are applied and the feature is used, the generated SQL query does not include the filters, resulting in the display of raw records instead of the filtered records in the drill down.

How to reproduce the bug

  1. Create a Virtual Dataset:

    SalesDataset:
    SELECT
        region,
        customer_name,
        sales_usd
    FROM public.sales
    WHERE 1 = 1
    {% if filter_values('company')|length %}
        AND company IN {{ filter_values('company')|where_in }}
    {% endif %}
  2. Create a Virtual Dataset for Filter:

    CompanyFilterDataSet:
    SELECT DISTINCT company AS company
    FROM public.sales
  3. Create a Pivot Table Chart:

    • DataSet: SalesDataset
    • Rows: region
    • Column: customer_name
    • Metric: count(sales_usd)
  4. Create a Dashboard Filter:

    • **Source: CompanyFilterDataSet
    • **Column: company
  5. **Test without Applying Filter:

    • **Use the "Drill to details by all" feature.
    • **The drill down shows the correct number of records.
  6. Apply Filter and Test Again:

    • **Apply a filter using the CompanyFilterDataSet.
    • **Notice that the values in the chart change according to the filter.
    • **Use the "Drill to details by all" feature.
    • **The drill down shows the original raw records (without the filter) instead of the filtered records.

Expected Behavior

The generated SQL query for the drill down should include the applied filters, and the drill down should display the filtered records.

Screenshots/recordings

ScreenRecording2024-05-17at5 36 03PM-ezgif com-video-to-gif-converter

Superset version

4.0.1

Python version

3.11

Node version

18 or greater

Browser

Chrome

Additional context

When creating a dashboard, I performed the following steps:

  • Created a dataset SalesDataset with a filter condition for company.
  • Created another dataset CompanyFilterDataSet for filtering companies.
  • Built a pivot table chart using SalesDataset, with region as rows, customer_name as columns, and count(sales_usd) as the metric.
  • Added a dashboard filter using CompanyFilterDataSet on the company column.
  • Initially, without applying any filters, the drill down feature shows the correct number of records. However, when a filter is applied, although the chart updates correctly, the drill down shows the original unfiltered records.

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

Metadata

Metadata

Assignees

Labels

dashboard:drill-downRelated to drill-down functionality of the Dashboardrequires:validationA committer should validate the issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions