You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/03/20 06:42:29 UTC

[GitHub] [incubator-druid] clintropolis edited a comment on issue #6974: sql support for dynamic parameters

clintropolis edited a comment on issue #6974: sql support for dynamic parameters
URL: https://github.com/apache/incubator-druid/pull/6974#issuecomment-474706200
 
 
   @peterlittig, I expect this will probably be merged to master within the next couple of weeks, barring any major issues uncovered during review, and should be included in release 0.15 (which is quickly sneaking up on us even though 0.14 isn't quite finalized yet).
   
   I'm not sure on your use case, but I hope so? I've attempted this PR to add general purpose support for dynamic parameters to Druid sql queries through both the JSON API and JDBC interfaces. I've added a handful of test cases for a variety of expressions to the new in this PR [CalciteParameterQueryTest](https://github.com/apache/incubator-druid/blob/a1038bcfdc503e531581b5ff87792c50dbc3bc73/sql/src/test/java/org/apache/druid/sql/calcite/CalciteParameterQueryTest.java), have a look to see if the queries you're trying to do look similar to any of those, and if not I'd be happy to add a test case to make sure it works correctly. 
   
   One thing to note, sometimes dynamic parameters can trip up the type inference, which will result in a query failing to validate before it can plan. As far as I can tell, this is largely on the calcite side, as queries will confuse the `SqlValidator` that parses the `SqlNode` prior to where this PR does it's thing, but there is a sort of work around for this through using a `CAST(? as <type>)` in the expression to explicitly type the parameters, e.g. like this example from the linked test cases:
   
   ```
   WHEN ? THEN SUM(cnt) / CAST(? as INT)
   ```
   
   In this example, the first `?` passes through the validator, but the 2nd must be explicitly cast to an `INT` to pass validation. It's unfortunate, but should get better with time and new versions.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org