This is an automated email from the ASF dual-hosted git repository.
suneet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new c86c48203e recommendation for comparing strings and numbers (#12442)
c86c48203e is described below
commit c86c48203edf67a696a6e64c677a4792ff26079e
Author: Victoria Lim <[email protected]>
AuthorDate: Mon Apr 18 09:28:32 2022 -0700
recommendation for comparing strings and numbers (#12442)
---
docs/querying/sql-syntax.md | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/docs/querying/sql-syntax.md b/docs/querying/sql-syntax.md
index c6a6ffb1ed..5ad78065c5 100644
--- a/docs/querying/sql-syntax.md
+++ b/docs/querying/sql-syntax.md
@@ -67,6 +67,21 @@ The WHERE clause refers to columns in the FROM table, and
will be translated to
WHERE clause can also reference a subquery, like `WHERE col1 IN (SELECT foo
FROM ...)`. Queries like this are executed
as a join on the subquery, described in the [Query
translation](sql-translation.md#subqueries) section.
+Strings and numbers can be compared in the WHERE clause of a SQL query through
implicit type conversion.
+For example, you can evaluate `WHERE stringDim = 1` for a string-typed
dimension named `stringDim`.
+However, for optimal performance, you should explicitly cast the reference
number as a string when comparing against a string dimension:
+```
+WHERE stringDim = '1'
+```
+
+Similarly, if you compare a string-typed dimension with reference to an array
of numbers, cast the numbers to strings:
+```
+WHERE stringDim IN ('1', '2', '3')
+```
+
+Note that explicit type casting does not lead to significant performance
improvement when comparing strings and numbers involving numeric dimensions
since numeric dimensions are not indexed.
+
+
## GROUP BY
The GROUP BY clause refers to columns in the FROM table. Using GROUP BY,
DISTINCT, or any aggregation functions will
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]