malloy icon indicating copy to clipboard operation
malloy copied to clipboard

Compilation error when using nested queries with `declare`

Open carlineng opened this issue 1 year ago • 1 comments

I have a query in a source that uses the declare keyword (sales_summary), and I'm trying to run the query on unaggregated data, and then re-use it in a nest, e.g.,:

  query: sales_summary_by_dept is sales_summary + {
    nest: by_dept is sales_summary + {
      group_by: inventory_items.product.department
    }
  }

This should give me the overall results of sales_summary, and also the results of sales_summary by department.

Instead, I'm getting:

line 257: INTERNAL ERROR model/Segment.nextStructDef: Redefinition of total_sales_2022

If I re-write the query so it doesn't use the declare keyword and instead just duplicate all the aggregation code, or if I define the measure on the Source, it works fine. See this example query in GitHub.

carlineng avatar May 04 '23 00:05 carlineng

does this break in the world of extend: { instead of declare:

mtoy-googly-moogly avatar Sep 22 '23 17:09 mtoy-googly-moogly