Akshat-Jain commented on code in PR #16358:
URL: https://github.com/apache/druid/pull/16358#discussion_r1591884078
##########
sql/src/main/java/org/apache/druid/sql/calcite/planner/PlannerContext.java:
##########
@@ -343,6 +349,28 @@ public String getSchemaResourceType(String schema, String
resourceName)
return plannerToolbox.rootSchema().getResourceType(schema, resourceName);
}
+ /**
+ * Add a lookup name to load in the lookup loading spec.
+ */
+ public void addLookupToLoad(String lookupName)
+ {
+ if (lookupLoadingSpec.getLookupsToLoad() == null) {
+ lookupLoadingSpec =
LookupLoadingSpec.loadOnly(Collections.singleton(lookupName));
+ } else {
+ Set<String> existingLookupsToLoad = new
HashSet<>(lookupLoadingSpec.getLookupsToLoad());
+ existingLookupsToLoad.add(lookupName);
+ lookupLoadingSpec = LookupLoadingSpec.loadOnly(existingLookupsToLoad);
Review Comment:
@kfaraz Karan suggested that we can make `LookupLoadingSpec#lookupsToLoad`
as a mutable Set, instead of the current ImmutableSet.
LookupLoadingSpec#getLookupsToLoad() can return an immutable set.
With the above changes, I'm adding the following method in LookupLoadingSpec:
```java
public void addLookupToLoad(String lookupName)
{
mode = Mode.ONLY_REQUIRED;
if (lookupsToLoad == null) {
lookupsToLoad = new HashSet<>(Collections.singletonList(lookupName));
} else {
lookupsToLoad.add(lookupName);
}
}
```
This required making the class variables non-final, but helps in a cleaner
usage everywhere else.
Hope this works.
cc: @cryptoe
--
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]