ccaominh commented on a change in pull request #6974: sql support for dynamic 
parameters
URL: https://github.com/apache/incubator-druid/pull/6974#discussion_r311271787
 
 

 ##########
 File path: 
sql/src/main/java/org/apache/druid/sql/calcite/planner/PlannerContext.java
 ##########
 @@ -58,23 +60,27 @@
   private final PlannerConfig plannerConfig;
   private final DateTime localNow;
   private final Map<String, Object> queryContext;
+  private final List<TypedValue> parameters;
   private final AuthenticationResult authenticationResult;
   private final String sqlQueryId;
   private final List<String> nativeQueryIds = new CopyOnWriteArrayList<>();
 
+
   private PlannerContext(
       final DruidOperatorTable operatorTable,
       final ExprMacroTable macroTable,
       final PlannerConfig plannerConfig,
       final DateTime localNow,
       final Map<String, Object> queryContext,
+      final List<TypedValue> parameters,
       final AuthenticationResult authenticationResult
   )
   {
     this.operatorTable = operatorTable;
     this.macroTable = macroTable;
     this.plannerConfig = Preconditions.checkNotNull(plannerConfig, 
"plannerConfig");
     this.queryContext = queryContext != null ? new HashMap<>(queryContext) : 
new HashMap<>();
+    this.parameters = parameters != null ? parameters : ImmutableList.of();
 
 Review comment:
   Allowing `null` can make it more difficult to realize that a code path 
forgot to correctly set the parameters. For example, in 
`DruidStatement#execute()`,         `sqlLifecycle.setParameters(parameters)` 
needs to be called before `sqlLifecycle.planAndAuthorize(authenticationResult)`.
   
   Perhaps it's better to assert that it's not null and have the caller 
explicitly pass in an empty parameter list if parameters are not relevant?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to