1
0
mirror of https://github.com/apache/druid.git synced 2025-02-12 21:15:00 +00:00

Document type inference issues with dynamic params in SQL ()

* Clarify docs

* Apply suggestions from code review

Co-authored-by: Charles Smith <38529548+techdocsmith@users.noreply.github.com>

Co-authored-by: Charles Smith <38529548+techdocsmith@users.noreply.github.com>
This commit is contained in:
Atul Mohan 2021-03-04 05:48:11 -06:00 committed by GitHub
parent 87a2abff79
commit be2ac8d6ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -219,6 +219,18 @@ at execution time. To use dynamic parameters, replace any literal in the query w
corresponding parameter value when you execute the query. Parameters are bound to the placeholders in the order in corresponding parameter value when you execute the query. Parameters are bound to the placeholders in the order in
which they are passed. Parameters are supported in both the [HTTP POST](#http-post) and [JDBC](#jdbc) APIs. which they are passed. Parameters are supported in both the [HTTP POST](#http-post) and [JDBC](#jdbc) APIs.
In certain cases, using dynamic parameters in expressions can cause type inference issues which cause your query to fail, for example:
```sql
SELECT * FROM druid.foo WHERE dim1 like CONCAT('%', ?, '%')
```
To solve this issue, explicitly provide the type of the dynamic parameter using the `CAST` keyword. Consider the fix for the preceding example:
```
SELECT * FROM druid.foo WHERE dim1 like CONCAT('%', CAST (? AS VARCHAR), '%')
```
## Data types ## Data types
### Standard types ### Standard types