kgyrtkirk commented on code in PR #16431:
URL: https://github.com/apache/druid/pull/16431#discussion_r1604458319
##########
sql/src/main/java/org/apache/druid/sql/calcite/planner/PlannerConfig.java:
##########
@@ -428,4 +430,28 @@ public PlannerConfig build()
return config;
}
}
+
+ public Map<String, Object> getNonDefaultAsQueryContext()
+ {
+ Map<String, Object> overrides = new HashMap<>();
+ PlannerConfig def = new PlannerConfig();
+ if (def.useApproximateCountDistinct != useApproximateCountDistinct) {
+ overrides.put(
+ CTX_KEY_USE_APPROXIMATE_COUNT_DISTINCT,
+ String.valueOf(useApproximateCountDistinct)
+ );
+ }
+ if (def.useGroupingSetForExactDistinct != useGroupingSetForExactDistinct) {
+ overrides.put(
+ CTX_KEY_USE_GROUPING_SET_FOR_EXACT_DISTINCT,
+ String.valueOf(useGroupingSetForExactDistinct)
+ );
+ }
+
+ PlannerConfig newConfig =
PlannerConfig.builder().withOverrides(overrides).build();
+ if (!equals(newConfig)) {
+ throw new IAE("Some configs are not handled in this method or not
persistable as QueryContext keys!\nold: %s\nnew: %s", this, newConfig);
+ }
Review Comment:
let me share a small back-story for this:
* for `BaseCalciteQueryTest#testBuilder` someone can specify `queryContext`
and `plannerConfig` as well - however most of the `plannerContext` settings can
be achieved by setting `queryContext` variables
* the quidem tests only support changes to the queryContext - so there was a
need to retrieve the settings from the `plannerConfig` in `queryContext` form
* I believe at some point it would be better to have `PlannerConfig` as an
implicit settings class which is implicitly defined by the `queryContext`
settings
this method was just needed in that process - I've change the exception
message to
```
Not all PlannerConfig options are not persistable as QueryContext
keys!\nold: %s\nnew: %s
```
and used `DruidException.defensive` instead; as only a developer could fix
this issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]