malloy icon indicating copy to clipboard operation
malloy copied to clipboard

exclude(.., dimension) checking doesn't apply in measure: statements

Open mtoy-googly-moogly opened this issue 1 year ago • 0 comments

exclude(expr, dimension_name) in an aggregate statement is checked at compile time, and if the dimension is not a grouping file for the query operation, or a query operation this query is nested in, it errors.

In a measure statement, the only check is that dimension_name exists and is not an aggregate.

Which means when a query is run containing a measure with an exclude() or all() which references a dimension which is NOT in the grouping hierarchy, this won't be noticed by the compiler and will get a runtime error, which is not a helpful user experience.

The fix is probably something like each FieldDef with an expression might have a requiredGrouping: [] which could be then checked by the compiler.

mtoy-googly-moogly avatar Nov 17 '23 19:11 mtoy-googly-moogly