New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Field Filter Category - Allow no default value for optional clause #5541
Comments
Here's some handy debug logs, with some info redacted. Query:
Debug:
The bit to focus on here is the subselect from |
Looks like it's related to this area of code: https://github.com/metabase/metabase/blob/master/src/metabase/query_processor/middleware/parameters/sql.clj#L165 @camsaul As you were the author of this bit, wanna weigh into what you think's up? 😸 |
Digging into the frontend a little I can see that the Whereas if I checkout the the This seems to add up to my comment ☝️ addressing |
I had another usecase that lead to this bug. See #8112 |
I'd like to bump this bug, as I'm seeing the same behaviour, and I notice that in both cases the variable is within a subquery:
And the query i get in the returned is below, not the use of AND venue = 1 = 1 instead of just omitting the whole line: orig.year as year,
orig.quarter as quarter,
orig.month as month,
orig.sum as current_sum,
orig.count as current_count,
orig.average as current_avg,
prevyear.sum as prevyear_sum,
prevyear.count as prevyear_count,
prevyear.average as prevyear_avg
FROM
(
SELECT
year(event_start_datetime) as year,
quarter(event_start_datetime) as quarter,
month(event_start_datetime) as month,
sum(cost) AS sum,
count(cost) AS count,
sum(cost) / count(cost) AS average
FROM
_reports_booked_jumpers
WHERE 1=1
AND venue = 1 = 1
GROUP BY
year,
quarter,
month
ORDER BY
year DESC,
quarter DESC,
month DESC
) as orig |
Community post about the same issue: https://discourse.metabase.com/t/option-clause-for-field-filter-in-native-sql-parameter/6193 This would allow us dinamically hide or show columns according to the user selection |
Fixed by #10947 |
Category Field Filters should allow no default option, so they can be used properly in optional clauses
Reproduce
Example clause:
These field filter settings
This 'optional clause' is always included in the native query, even when the widget has no value set.
Desired Behaviour
There should be a "No Default" field, which is the default (default no default 🤔)
EG:
When "No Default" is used on this widget, then the clause should be optional and excluded from the native query that's constructed, similar to other, non-fieldfilter widgets.
The text was updated successfully, but these errors were encountered: