From a3f3e4407350f8d0de6de30a3e92233fc0eb7a11 Mon Sep 17 00:00:00 2001 From: writer-jill Date: Thu, 23 Jan 2025 14:54:41 +0000 Subject: [PATCH 01/12] Batch19 SQL aggregation functions --- docs/querying/sql-functions.md | 67 +++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index 666e06d548d0..23681b44ff87 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -371,19 +371,74 @@ Returns the bitwise exclusive OR between the two expressions, that is, `expr1 ^ ## BLOOM_FILTER -`BLOOM_FILTER(expr, )` +Computes a [bloom filter](../development/extensions-core/bloom-filter.md) from values provided in an expression. -**Function type:** [Aggregation](sql-aggregations.md) +`numEntries` specifies the maximum number of distinct values before the false positive rate increases. + +* **Syntax:** `BLOOM_FILTER(expr, numEntries)` +* **Function type:** SQL aggregation + +
Example + +The following example returns a base64-encoded bloom filter string for entries in agent_category, +with a maximum of 10 distinct values: + +```sql +SELECT + agent_category, + BLOOM_FILTER(agent_category, 10) as bloom +FROM "kttm" + GROUP BY agent_category +``` + +Returns the following: + +| `agent_keys` | `bloom` | +| -- | -- | +| _`empty`_ | `"BAAAAAgAAAAAABAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEABAAAAAA"` | +| `Game console` | `"BAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAQAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgBAAAAAAAAAAAAAAAA"` | +| `Personal computer` | `"BAAAAAgAAAAAAEAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA"` | +| `Smart TV` | `"BAAAAAgAAAAAAAAAAAAAgAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAA"` | +| `Smartphone` | `"BAAAAAgAAACAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAA"` | +| `Tablet` | `"BAAAAAgAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAIA"` | + +
-Computes a Bloom filter from values produced by the specified expression. +[Learn more](sql-aggregations.md) ## BLOOM_FILTER_TEST -`BLOOM_FILTER_TEST(expr, )` +Returns true if an expression is contained in a base64-encoded [bloom filter](../development/extensions-core/bloom-filter.md) string. -**Function type:** [Scalar, other](sql-scalar.md#other-scalar-functions) +* **Syntax:** `BLOOM_FILTER_TEST(expr, )` +* **Function type:** SQL aggregation + +
Example + +The following example returns `true` for the bloom filter string associated with `agent_filter` entry `Game console`: + +```sql +SELECT + agent_category, + BLOOM_FILTER_TEST(agent_category, 'BAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAQAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgBAAAAAAAAAAAAAAAA') as bloom +FROM "kttm" +GROUP BY agent_category +``` + +Returns the following: + +| `agent_keys` | `bloom` | +| -- | -- | +| _`empty`_ | `false` | +| `Game console` | `true` | +| `Personal computer` | `false` | +| `Smart TV` | `false` | +| `Smartphone` | `false` | +| `Tablet` | `false` | + +
-Returns true if the expression is contained in a Base64-serialized Bloom filter. +[Learn more](sql-aggregations.md) ## BTRIM From bb9e674da65ac64f6e76d07ec525b25456043e8b Mon Sep 17 00:00:00 2001 From: writer-jill Date: Thu, 23 Jan 2025 17:33:41 +0000 Subject: [PATCH 02/12] Updated --- docs/querying/sql-functions.md | 54 +++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index 23681b44ff87..c7ac433abe7e 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -376,12 +376,11 @@ Computes a [bloom filter](../development/extensions-core/bloom-filter.md) from v `numEntries` specifies the maximum number of distinct values before the false positive rate increases. * **Syntax:** `BLOOM_FILTER(expr, numEntries)` -* **Function type:** SQL aggregation +* **Function type:** Aggregation
Example -The following example returns a base64-encoded bloom filter string for entries in agent_category, -with a maximum of 10 distinct values: +The following example returns a base64-encoded bloom filter string for entries in `agent_category`: ```sql SELECT @@ -411,7 +410,7 @@ Returns the following: Returns true if an expression is contained in a base64-encoded [bloom filter](../development/extensions-core/bloom-filter.md) string. * **Syntax:** `BLOOM_FILTER_TEST(expr, )` -* **Function type:** SQL aggregation +* **Function type:** Aggregation
Example @@ -580,20 +579,55 @@ Rounds down a timestamp by a given time unit. ## DECODE_BASE64_COMPLEX -`DECODE_BASE64_COMPLEX(dataType, expr)` +Decodes a base64-encoded expression into a complex data type. -**Function type:** [Scalar, other](sql-scalar.md#other-scalar-functions) +* **Syntax:** `DECODE_BASE64_COMPLEX(dataType, expr)` +* **Function type:** Scalar + +
Example + +The following example decodes the base64-encoded representation of "Hello, World!": + +```sql +SELECT + DECODE_BASE64_COMPLEX('thetaSketch', "theta_input") as theta +``` + +Returns the following: + +| `agent_keys` | +| -- | +| `Hello, World!` | + +
-Decodes a Base64-encoded string into a complex data type, where `dataType` is the complex data type and `expr` is the Base64-encoded string to decode. +[Learn more](./sql-scalar.md#other-scalar-functions) ## DECODE_BASE64_UTF8 -`DECODE_BASE64_UTF8(expr)` +Decodes a base64-encoded expression into a UTF-8 encoded string. -**Function type:** [Scalar, string](sql-scalar.md#string-functions) +* **Syntax:** `DECODE_BASE64_UTF8(expr)` +* **Function type:** Scalar + +
Example + +The following example decodes the base64-encoded representation of "Hello, World!": + +```sql +SELECT + DECODE_BASE64_UTF8('SGVsbG8sIFdvcmxkIQ==') as decoded +``` + +Returns the following: + +| `agent_keys` | +| -- | +| `Hello, World!` | +
-Decodes a Base64-encoded string into a UTF-8 encoded string. +[Learn more](./sql-scalar.md#string-functions) ## DEGREES From 13c6dd2c3e494c3c07cc453359aefd8ce5be85fa Mon Sep 17 00:00:00 2001 From: writer-jill Date: Fri, 24 Jan 2025 17:20:14 +0000 Subject: [PATCH 03/12] Updated --- docs/querying/sql-functions.md | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index c7ac433abe7e..9f6d56cba582 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -581,23 +581,34 @@ Rounds down a timestamp by a given time unit. Decodes a base64-encoded expression into a complex data type. +You can use the function to ingest data when a column contains an encoded data sketch such as Theta or HLL. + +The function supports `hyperUnique` and `serializablePairLongString` data types by default. +You can enable support for the following complex data types by [loading their extensions](../configuration/extensions.md): + +- `druid-bloom-filter`: `bloom` +- `druid-datasketches`: `arrayOfDoublesSketch`, `HLLSketch`, `KllDoublesSketch`, `KllFloatsSketch`, `quantilesDoublesSketch`, `thetaSketch` +- `druid-histogram`: `approximateHistogram`, `fixedBucketsHistogram` +- `druid-stats`: `variance` +- `druid-compressed-bigdecimal`: `compressedBigDecimal` +- `druid-momentsketch`: `momentSketch` +- `druid-tdigestsketch`: `tDigestSketch` + * **Syntax:** `DECODE_BASE64_COMPLEX(dataType, expr)` * **Function type:** Scalar
Example -The following example decodes the base64-encoded representation of "Hello, World!": +The following example decodes a Theta sketch from a base64-encoded sketch contained in `theta_input`: ```sql -SELECT - DECODE_BASE64_COMPLEX('thetaSketch', "theta_input") as theta +DECODE_BASE64_COMPLEX('thetaSketch', "theta_input") ``` +The following example counts the distinct values in an encoded Theta sketch column using [`APPROX_COUNT_DISTINCT_DS_THETA`](#approx_count_distinct_ds_theta): -Returns the following: - -| `agent_keys` | -| -- | -| `Hello, World!` | +```sql +APPROX_COUNT_DISTINCT_DS_THETA(DECODE_BASE64_COMPLEX('thetaSketch', "theta_input")) +```
From 4af670bea90a6d202fcdea1ef558c6ca5c465b95 Mon Sep 17 00:00:00 2001 From: Jill Osborne Date: Mon, 27 Jan 2025 14:00:36 +0000 Subject: [PATCH 04/12] Update docs/querying/sql-functions.md Co-authored-by: Victoria Lim --- docs/querying/sql-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index 4a85c708476f..854a6d919090 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -1849,7 +1849,7 @@ APPROX_COUNT_DISTINCT_DS_THETA(DECODE_BASE64_COMPLEX('thetaSketch', "theta_input Decodes a base64-encoded expression into a UTF-8 encoded string. * **Syntax:** `DECODE_BASE64_UTF8(expr)` -* **Function type:** Scalar +* **Function type:** Scalar, string
Example From cf8c9b4effc370d59de956417bdcaf91594f60ce Mon Sep 17 00:00:00 2001 From: writer-jill Date: Mon, 27 Jan 2025 14:19:13 +0000 Subject: [PATCH 05/12] Updated after review --- docs/querying/sql-functions.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index 854a6d919090..82d665af3aca 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -1291,7 +1291,7 @@ Computes a [bloom filter](../development/extensions-core/bloom-filter.md) from v
Example -The following example returns a base64-encoded bloom filter string for entries in `agent_category`: +The following example returns a Base64-encoded bloom filter string for entries in `agent_category`: ```sql SELECT @@ -1305,7 +1305,7 @@ Returns the following: | `agent_keys` | `bloom` | | -- | -- | -| _`empty`_ | `"BAAAAAgAAAAAABAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEABAAAAAA"` | +| `empty` | `"BAAAAAgAAAAAABAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEABAAAAAA"` | | `Game console` | `"BAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAQAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgBAAAAAAAAAAAAAAAA"` | | `Personal computer` | `"BAAAAAgAAAAAAEAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA"` | | `Smart TV` | `"BAAAAAgAAAAAAAAAAAAAgAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAA"` | @@ -1318,10 +1318,10 @@ Returns the following: ## BLOOM_FILTER_TEST -Returns true if an expression is contained in a base64-encoded [bloom filter](../development/extensions-core/bloom-filter.md) string. +Returns true if an expression is contained in a Base64-encoded [bloom filter](../development/extensions-core/bloom-filter.md) string. * **Syntax:** `BLOOM_FILTER_TEST(expr, )` -* **Function type:** Aggregation +* **Function type:** Scalar, other
Example @@ -1809,7 +1809,7 @@ Returns the following: ## DECODE_BASE64_COMPLEX -Decodes a base64-encoded expression into a complex data type. +Decodes a Base64-encoded expression into a complex data type. You can use the function to ingest data when a column contains an encoded data sketch such as Theta or HLL. @@ -1829,7 +1829,7 @@ You can enable support for the following complex data types by [loading their ex
Example -The following example decodes a Theta sketch from a base64-encoded sketch contained in `theta_input`: +The following example decodes a Theta sketch from a Base64-encoded sketch contained in `theta_input`: ```sql DECODE_BASE64_COMPLEX('thetaSketch', "theta_input") @@ -1846,14 +1846,14 @@ APPROX_COUNT_DISTINCT_DS_THETA(DECODE_BASE64_COMPLEX('thetaSketch', "theta_input ## DECODE_BASE64_UTF8 -Decodes a base64-encoded expression into a UTF-8 encoded string. +Decodes a Base64-encoded expression into a UTF-8 encoded string. * **Syntax:** `DECODE_BASE64_UTF8(expr)` * **Function type:** Scalar, string
Example -The following example decodes the base64-encoded representation of "Hello, World!": +The following example decodes the Base64-encoded representation of "Hello, World!": ```sql SELECT From 700b61fec6eee066e2bdc7f02da61fe9e2de4e9f Mon Sep 17 00:00:00 2001 From: Jill Osborne Date: Mon, 27 Jan 2025 19:02:19 +0000 Subject: [PATCH 06/12] Removed some problematic italics --- docs/querying/sql-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index 82d665af3aca..079df508099c 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -1339,7 +1339,7 @@ Returns the following: | `agent_keys` | `bloom` | | -- | -- | -| _`empty`_ | `false` | +| `empty` | `false` | | `Game console` | `true` | | `Personal computer` | `false` | | `Smart TV` | `false` | From 6f1e3ee161f730847e1aa566feb51e58f3f8ea01 Mon Sep 17 00:00:00 2001 From: writer-jill Date: Wed, 29 Jan 2025 11:21:34 +0000 Subject: [PATCH 07/12] Updated after review --- docs/querying/sql-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index 079df508099c..784939e75348 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -1348,7 +1348,7 @@ Returns the following:
-[Learn more](sql-aggregations.md) +[Learn more](sql-scalar.md#other-scalar-functions) ## BTRIM From ed8a764b240fcdb1a1a82c5637e5d2ed1f5b4331 Mon Sep 17 00:00:00 2001 From: Jill Osborne Date: Wed, 29 Jan 2025 11:21:57 +0000 Subject: [PATCH 08/12] Update docs/querying/sql-functions.md Co-authored-by: Victoria Lim --- docs/querying/sql-functions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index 784939e75348..7fc6edaa7307 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -1284,9 +1284,9 @@ Returns the following: Computes a [bloom filter](../development/extensions-core/bloom-filter.md) from values provided in an expression. -`numEntries` specifies the maximum number of distinct values before the false positive rate increases. -* **Syntax:** `BLOOM_FILTER(expr, numEntries)` +* **Syntax:** `BLOOM_FILTER(expr, numEntries)` + `numEntries` specifies the maximum number of distinct values before the false positive rate increases. * **Function type:** Aggregation
Example From a7b42256c96890f89700c2162f20fba9c44d3939 Mon Sep 17 00:00:00 2001 From: Jill Osborne Date: Wed, 29 Jan 2025 11:22:06 +0000 Subject: [PATCH 09/12] Update docs/querying/sql-functions.md Co-authored-by: Victoria Lim --- docs/querying/sql-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index 7fc6edaa7307..a6636d3038cb 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -1825,7 +1825,7 @@ You can enable support for the following complex data types by [loading their ex - `druid-tdigestsketch`: `tDigestSketch` * **Syntax:** `DECODE_BASE64_COMPLEX(dataType, expr)` -* **Function type:** Scalar +* **Function type:** Scalar, other
Example From c060f3ed4fc3b95ea257bc18b6a9ab7273802d9c Mon Sep 17 00:00:00 2001 From: writer-jill Date: Wed, 29 Jan 2025 11:23:45 +0000 Subject: [PATCH 10/12] Capitalize Bloom --- docs/querying/sql-functions.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index a6636d3038cb..9c058b41197f 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -1282,7 +1282,7 @@ Returns the following: ## BLOOM_FILTER -Computes a [bloom filter](../development/extensions-core/bloom-filter.md) from values provided in an expression. +Computes a [Bloom filter](../development/extensions-core/bloom-filter.md) from values provided in an expression. * **Syntax:** `BLOOM_FILTER(expr, numEntries)` @@ -1291,7 +1291,7 @@ Computes a [bloom filter](../development/extensions-core/bloom-filter.md) from v
Example -The following example returns a Base64-encoded bloom filter string for entries in `agent_category`: +The following example returns a Base64-encoded Bloom filter string for entries in `agent_category`: ```sql SELECT @@ -1318,14 +1318,14 @@ Returns the following: ## BLOOM_FILTER_TEST -Returns true if an expression is contained in a Base64-encoded [bloom filter](../development/extensions-core/bloom-filter.md) string. +Returns true if an expression is contained in a Base64-encoded [Bloom filter](../development/extensions-core/bloom-filter.md) string. * **Syntax:** `BLOOM_FILTER_TEST(expr, )` * **Function type:** Scalar, other
Example -The following example returns `true` for the bloom filter string associated with `agent_filter` entry `Game console`: +The following example returns `true` for the Bloom filter string associated with `agent_filter` entry `Game console`: ```sql SELECT From b493af4317a9d57de3d5fa543678d2c3f75d0ad7 Mon Sep 17 00:00:00 2001 From: Charles Smith Date: Tue, 4 Feb 2025 16:06:37 -0800 Subject: [PATCH 11/12] Apply suggestions from code review Apply suggestions --- docs/querying/sql-functions.md | 54 ++++++++++++++-------------------- 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index 9c058b41197f..b2a48060f2ab 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -1291,26 +1291,21 @@ Computes a [Bloom filter](../development/extensions-core/bloom-filter.md) from v
Example -The following example returns a Base64-encoded Bloom filter string for entries in `agent_category`: +The following example returns a Base64-encoded Bloom filter representing the set of devices ,`agent_category`, used in Albania: ```sql -SELECT - agent_category, - BLOOM_FILTER(agent_category, 10) as bloom +SELECT "country", + BLOOM_FILTER(agent_category, 10) as albanian_bloom FROM "kttm" - GROUP BY agent_category +WHERE "country" = 'Albania' +GROUP BY "country" ``` Returns the following: -| `agent_keys` | `bloom` | -| -- | -- | -| `empty` | `"BAAAAAgAAAAAABAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEABAAAAAA"` | -| `Game console` | `"BAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAQAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgBAAAAAAAAAAAAAAAA"` | -| `Personal computer` | `"BAAAAAgAAAAAAEAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA"` | -| `Smart TV` | `"BAAAAAgAAAAAAAAAAAAAgAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAA"` | -| `Smartphone` | `"BAAAAAgAAACAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAA"` | -| `Tablet` | `"BAAAAAgAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAIA"` | +|`country`| `albanian_bloom`| +|---| --- | +|`Albania`|`BAAAAAgAAACAAEAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAIIAAAAAAAAAAAAAAAAAAIAAAAAAQAAAAAAAAAAAAAA`|
@@ -1325,25 +1320,23 @@ Returns true if an expression is contained in a Base64-encoded [Bloom filter](..
Example -The following example returns `true` for the Bloom filter string associated with `agent_filter` entry `Game console`: +The following example returns `true` when a device type, `agent_category`, exists in the Bloom filter representing the set of devices used in Albania: ```sql -SELECT - agent_category, - BLOOM_FILTER_TEST(agent_category, 'BAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAQAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgBAAAAAAAAAAAAAAAA') as bloom +SELECT agent_category, +BLOOM_FILTER_TEST("agent_category", 'BAAAAAgAAACAAEAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAIIAAAAAAAAAAAAAAAAAAIAAAAAAQAAAAAAAAAAAAAA') AS bloom_test FROM "kttm" -GROUP BY agent_category -``` +GROUP BY 1``` Returns the following: -| `agent_keys` | `bloom` | -| -- | -- | +| `agent_category` | `bloom_test` | +| --- | --- | | `empty` | `false` | -| `Game console` | `true` | -| `Personal computer` | `false` | +| `Game console` | `false` | +| `Personal computer` | `true` | | `Smart TV` | `false` | -| `Smartphone` | `false` | +| `Smartphone` | `true` | | `Tablet` | `false` |
@@ -1814,7 +1807,7 @@ Decodes a Base64-encoded expression into a complex data type. You can use the function to ingest data when a column contains an encoded data sketch such as Theta or HLL. The function supports `hyperUnique` and `serializablePairLongString` data types by default. -You can enable support for the following complex data types by [loading their extensions](../configuration/extensions.md): +To enable support for a complex data type, load the [corresponding extension](../configuration/extensions.md): - `druid-bloom-filter`: `bloom` - `druid-datasketches`: `arrayOfDoublesSketch`, `HLLSketch`, `KllDoublesSketch`, `KllFloatsSketch`, `quantilesDoublesSketch`, `thetaSketch` @@ -1829,16 +1822,13 @@ You can enable support for the following complex data types by [loading their ex
Example -The following example decodes a Theta sketch from a Base64-encoded sketch contained in `theta_input`: +The following example returns a Theta sketch complex type from a Base64-encoded string representation of the sketch: ```sql -DECODE_BASE64_COMPLEX('thetaSketch', "theta_input") +SELECT DECODE_BASE64_COMPLEX('thetaSketch','AgMDAAAazJNBAAAAAACAP+k/tkWGkSoFYWMAG0y+3gVabvKcIUNrBv0jAkGsw7sK5szX1k0ScwtMfCQmFP/rDhFK6yU7PPkObZ/Ugw5fcBQZ+GaO+Nt6FP+Whz6TmxkWyRJ+gaQLFhcts1+c0Q/vF9FLFfaVlOkb3/XpXaZ3JhyZ2dG8Di2/HO10sMs9C0AdM4FdHuye6SB+GYinIhTOITOHzB5SAfIiph3de9qIGSM89V+s/TkdI/WZVzK9wF0npfi4ZrmgBSnVjphCtQA5K2fp0x59UCwvMopZarsSkzEo81OIxjznNNXLr1BbQBo1Ei3OxJOoNzVs0x9xzsm4NfgAZSvZQvI1c2TmPsZvlzpW7tmIlizOOsr6pGWoh0U99/tV8RFwhz0SJoWyU1Z2P0hZ5d7KRnZBjlWC+e/FLEKrWsu14rlFRXhsOuxRId9FboEuH9PqMUixI2lB8MhLS803hJDoZ7tMy7Egl+YNU04QM11stXX4Tu96NHHcGiZRuCyciGiTGVQflMLmNt6lW6zIwJy0baNdbwjMCTjtUF7oZOtugWLYYJE9sJU3HuVijc0J10l6SmPslbfY6Fw0Za9w/Zdhn/5nIuKc1WMrYWnAJQJKXY73bHYWq7gI6dRvYdC2fLJyv3F8qwQcOJgFc0GaGXw8KRF3w3IVCwxsMntWhdTkaJ88e++5NFyM1Hd/D79wg0b9vH8=') AS "theta_sketch" ``` -The following example counts the distinct values in an encoded Theta sketch column using [`APPROX_COUNT_DISTINCT_DS_THETA`](#approx_count_distinct_ds_theta): -```sql -APPROX_COUNT_DISTINCT_DS_THETA(DECODE_BASE64_COMPLEX('thetaSketch', "theta_input")) -``` +You can perform Theta sketch operations on the resulting `COMPLEX` value which resembles the input string.
@@ -1862,7 +1852,7 @@ SELECT Returns the following: -| `agent_keys` | +| `decoded` | | -- | | `Hello, World!` | From 455739482867476bf924d85f8fa0d961e82307f3 Mon Sep 17 00:00:00 2001 From: Victoria Lim Date: Tue, 4 Feb 2025 16:52:42 -0800 Subject: [PATCH 12/12] fix backticks --- docs/querying/sql-functions.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index b2a48060f2ab..f0fb70fa9a4c 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -1326,7 +1326,8 @@ The following example returns `true` when a device type, `agent_category`, exist SELECT agent_category, BLOOM_FILTER_TEST("agent_category", 'BAAAAAgAAACAAEAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAIIAAAAAAAAAAAAAAAAAAIAAAAAAQAAAAAAAAAAAAAA') AS bloom_test FROM "kttm" -GROUP BY 1``` +GROUP BY 1 +``` Returns the following: