-
- Downloads
Change run to make-run in process-query-for-card (#44244)
* Change run to make-run in process-query-for-card Fixes #44160 There were two levers where a card could change how it was run. `qp` this is basically `qp/process-query` with some optional userland flags and constraints marked on the passed in query. In the case of pivot tables in the `/pivot/:card-id/query` endpoints it was `qp.pivot/process-query` 'run' this defaults to a streaming response that takes the `qp` param and `export-format` and passes a query to qp. Most often this is overriden to not stream the response. Unfortunately, if `run` is overwritten, then `qp` is thrown away, and the caller who overrides `run` must determine the correct `qp` to use. However, when running `process-query-for-dashcard` it is difficult to properly set `qp` for all of the dashcards without doing card lookups. So [this commit](https://github.com/metabase/metabase/blob/release-x.50.x/src/metabase/query_processor/card.clj#L230-L232) did a check to swap the runner in the presence of a pivot query that calls the **default** runner with a `qp.pivot/run-pivot-query`. The problem is that pulse needs to use a non-default runner, but there's no way for `process-query-for-card` to do both. This commit changes `run` to `make-run` which raises the abstraction to a function that produces a runer given a `qp`. This allows `process-query-for-card` to change the `qp` as needed while keeping the passed in runner. There's really three things going on that could be teased apart further/better. 1. `qp` - this conflates the processor (`qp/process-query` `qp.pivot/run-pivot-query`) and modifying query (`qp/userland-query`, `qp/userland-query-with-default-constraints` `(update query :info merge info)`) 2. `make-run` - How the above are processed: (streaming/realized) * Fix tests
Showing
- src/metabase/api/public.clj 4 additions, 3 deletionssrc/metabase/api/public.clj
- src/metabase/pulse/util.clj 13 additions, 11 deletionssrc/metabase/pulse/util.clj
- src/metabase/query_processor/card.clj 21 additions, 16 deletionssrc/metabase/query_processor/card.clj
- src/metabase/query_processor/dashboard.clj 1 addition, 1 deletionsrc/metabase/query_processor/dashboard.clj
- test/metabase/api/card_test.clj 2 additions, 2 deletionstest/metabase/api/card_test.clj
- test/metabase/query_processor/card_test.clj 19 additions, 6 deletionstest/metabase/query_processor/card_test.clj
- test/metabase/query_processor/dashboard_test.clj 3 additions, 2 deletionstest/metabase/query_processor/dashboard_test.clj
Please register or sign in to comment