From e8d0c8fd84d979242758fa822c9fd095815fcd52 Mon Sep 17 00:00:00 2001 From: benkrug Date: Thu, 13 May 2021 15:48:23 -0700 Subject: [PATCH 1/2] Update math-expr.md --- docs/misc/math-expr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/misc/math-expr.md b/docs/misc/math-expr.md index 174e7116b868..5384a814346e 100644 --- a/docs/misc/math-expr.md +++ b/docs/misc/math-expr.md @@ -50,7 +50,7 @@ Expressions can contain variables. Variable names may contain letters, digits, ' For logical operators, a number is true if and only if it is positive (0 or negative value means false). For string type, it's the evaluation result of 'Boolean.valueOf(string)'. -[Multi-value string dimensions](../querying/multi-value-dimensions.md) are supported and may be treated as either scalar or array typed values. When treated as a scalar type, an expression will automatically be transformed to apply the scalar operation across all values of the multi-valued type, to mimic Druid's native behavior. Values that result in arrays will be coerced back into the native Druid string type for aggregation. Druid aggregations on multi-value string dimensions on the individual values, _not_ the 'array', behaving similar to the `UNNEST` operator available in many SQL dialects. However, by using the `array_to_string` function, aggregations may be done on a stringified version of the complete array, allowing the complete row to be preserved. Using `string_to_array` in an expression post-aggregator, allows transforming the stringified dimension back into the true native array type. +[Multi-value string dimensions](../querying/multi-value-dimensions.md) are supported and may be treated as either scalar or array typed values. When treated as a scalar type, an expression will automatically be transformed to apply the scalar operation across all values of the multi-valued type, to mimic Druid's native behavior. Values that result in arrays will be coerced back into the native Druid string type for aggregation. Druid aggregations on multi-value string dimensions act on the individual values, _not_ the 'array', behaving similar to the `UNNEST` operator available in many SQL dialects. However, by using the `array_to_string` function, aggregations may be done on a stringified version of the complete array, allowing the complete row to be preserved. Using `string_to_array` in an expression post-aggregator, allows transforming the stringified dimension back into the true native array type. The following built-in functions are available. From e71314bdcef1885d7052d40b351fcbcec2a49ade Mon Sep 17 00:00:00 2001 From: benkrug Date: Mon, 9 Aug 2021 17:41:40 -0700 Subject: [PATCH 2/2] Update docs/misc/math-expr.md Co-authored-by: sthetland --- docs/misc/math-expr.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/misc/math-expr.md b/docs/misc/math-expr.md index 5384a814346e..ce1017ef6420 100644 --- a/docs/misc/math-expr.md +++ b/docs/misc/math-expr.md @@ -50,7 +50,9 @@ Expressions can contain variables. Variable names may contain letters, digits, ' For logical operators, a number is true if and only if it is positive (0 or negative value means false). For string type, it's the evaluation result of 'Boolean.valueOf(string)'. -[Multi-value string dimensions](../querying/multi-value-dimensions.md) are supported and may be treated as either scalar or array typed values. When treated as a scalar type, an expression will automatically be transformed to apply the scalar operation across all values of the multi-valued type, to mimic Druid's native behavior. Values that result in arrays will be coerced back into the native Druid string type for aggregation. Druid aggregations on multi-value string dimensions act on the individual values, _not_ the 'array', behaving similar to the `UNNEST` operator available in many SQL dialects. However, by using the `array_to_string` function, aggregations may be done on a stringified version of the complete array, allowing the complete row to be preserved. Using `string_to_array` in an expression post-aggregator, allows transforming the stringified dimension back into the true native array type. +[Multi-value string dimensions](../querying/multi-value-dimensions.md) are supported and may be treated as either scalar or array typed values, as follows: +* When treated as a scalar type, the expression is automatically transformed so that the scalar operation is applied across all values of the multi-valued type, mimicking Druid's native behavior. +* Values that result in arrays are coerced back into the native Druid string type for grouping and aggregation. Grouping on multi-value string dimensions in Druid will group by the individual values, not the 'array', resulting in behavior similar to the UNNEST operator available in many SQL dialects. Alternatively, you can use the `array_to_string` function to perform the aggregation on a _stringified_ version of the complete array, preserving the complete row. Using `string_to_array` in an expression post-aggregator transforms the stringified dimension back into the true native array type. The following built-in functions are available.