clintropolis commented on a change in pull request #6974: sql support for
dynamic parameters
URL: https://github.com/apache/druid/pull/6974#discussion_r370594734
##########
File path: sql/src/main/java/org/apache/druid/sql/avatica/DruidStatement.java
##########
@@ -152,27 +162,36 @@ public DruidStatement prepare(
try {
ensure(State.NEW);
sqlLifecycle.initialize(query, queryContext);
- sqlLifecycle.planAndAuthorize(authenticationResult);
+
+ this.authenticationResult = authenticationResult;
+ PrepareResult prepareResult =
sqlLifecycle.prepare(authenticationResult);
this.maxRowCount = maxRowCount;
this.query = query;
+ ArrayList<AvaticaParameter> params = new ArrayList<>();
+ final RelDataType parameterRowType =
prepareResult.getParameterRowType();
+ for (RelDataTypeField field : parameterRowType.getFieldList()) {
+ RelDataType type = field.getType();
+ params.add(
+ new AvaticaParameter(
+ false,
+ type.getPrecision(),
+ type.getScale(),
+ type.getSqlTypeName().getJdbcOrdinal(),
+ type.getSqlTypeName().getName(),
+ Object.class.getName(),
Review comment:
I initially copied a calcite statement default implementation that had hard
coded that value as such, and everything appeared to still work correctly for
druid statements with parameters, so I don't know that it particularly matters.
However, it seemed easy enough to do the right thing, so I added a static
utility method, `Calcites.sqlTypeNameJdbcToJavaClass` to do the conversion.
----------------------------------------------------------------
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]