coordinator: display dynamic filters after execution - #623
coordinator: display dynamic filters after execution#623jayshrivastava wants to merge 6 commits into
Conversation
2a2bffc to
f549dc2
Compare
|
Thanks for working on this: this will be very useful! One quick thought: the dynamic filter will sometimes be much, much larger than what you would actually want to display in an EXPLAIN plan (a large Also, I have a draft of a related change on our codebase, and it seemed like the easiest mechanism for transferring this kind of information back is via metrics... but the most natural/obvious thing that seemed to be missing in that case was essentially a "string" metric type (we would use it to display a chosen strategy/enum from a scan). Do you think that that might be worth pursuing upstream? |
Serializing them as a string is reasonable. Rather than a metric, I think we can implement a |
|
🤔 I'm not sure if I'm understanding the suggestion. Updating a filter with |
Stack
This stack of PRs implements distributed dynamic filtering #528
Closes: #529
Problem
Post df-55 upgrade, dynamic filters should work in the worker-local case. There's no way to observe them working other than looking at metrics.
Ideally we want the final filters visible when displaying plans.
Solution
This PR adds a new protocol which is basically identical to the metrics protocol. Even the
MetricsStoreis now justStoreand is generic overTaskMetricsandTaskCompletedDynamicFilters(contains completed dynamic filters for a task).Similar to the metrics protocol, workers now collect completed dynamic filters and send them back to the coordinator.
Then, at display time, we call
apply_reports_to_distributed_leaveswhich traverses theplan_for_vizand updates the dynamic filters for all the variants:Notes
Duplicate RPC Messages
We will eventually have more dynamic filter RPCs which manage the worker -> coordinator -> merge -> worker flow mentioned in #553.
In theory, the coordinator will know at
mergetime what the completed filters are, making theTaskCompletedDynamicFiltersand final worker -> coordinator message in this PR irrelevant.However, I think having these mechanisms be separate is good because a) it helps us validate that the dynamic filter coordinator -> worker flow work using external "oracle", and b) there's no guarantee that the coordinator -> worker propagation happens before the query is done (ex. the
DataSourceExecmay not block execution waiting for dynamic filters), so it's good to have a separate way to know if the finalDataSourceExecapplied a filter or not.AND trueand empty filtersIn this filter
AND trueoccurs because of apache/datafusion#24277. The firstDynamicFilteris active but we lose theHashTableLookupExprwhen serializing it to send back to the coordinator.The 2nd filter is
DynamicFilter [ empty ]because this is a dynamic filter produced by a remote producer, which does not get propagated to this node yet.Testing