You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "edgar2020 (via GitHub)" <gi...@apache.org> on 2024/08/09 21:24:54 UTC
[PR] [Docs] Batch09: only `lookup` (druid)
edgar2020 opened a new pull request, #16878:
URL: https://github.com/apache/druid/pull/16878
### Description
Add exampl to the sql-functions.md page
Updates the `lookup` function with map lookup table and sql.
This PR has:
- [X] been self-reviewed.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "ektravel (via GitHub)" <gi...@apache.org>.
ektravel commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1721864007
##########
docs/querying/sql-scalar.md:
##########
@@ -102,7 +102,7 @@ String functions accept strings and return a type appropriate to the function.
|`CHAR_LENGTH(expr)`|Alias for `LENGTH`.|
|`CHARACTER_LENGTH(expr)`|Alias for `LENGTH`.|
|`STRLEN(expr)`|Alias for `LENGTH`.|
-|`LOOKUP(expr, lookupName[, replaceMissingValueWith])`|Looks up `expr` in an existing [query-time lookup table](lookups.md) that has the name `lookupName`. Returns the optional constant `replaceMissingValueWith` when `expr` is null or when the lookup does not contain a value for `expr`.<br /><br />You can query lookups directly using the [`lookup` schema](sql.md#from).|
+|`LOOKUP(expr, lookupName[, replaceMissingValueWith])`|Look up `expr` in a registered [query-time lookup table](lookups.md) named `lookupName` and returns the mapped value. If `expr` is null or not contained in the lookup, returns `replaceMissingValueWith` if supplied, otherwise returns null.<br /><br />You can query lookups directly using the [`lookup` schema](sql.md#from).|
Review Comment:
```suggestion
|`LOOKUP(expr, lookupName[, replaceMissingValueWith])`|Searches for `expr` in a registered [query-time lookup table](lookups.md) named `lookupName` and returns the mapped value. If `expr` is null or not contained in the lookup, returns `replaceMissingValueWith` if supplied, otherwise returns null.<br /><br />You can query lookups directly using the [`lookup` schema](sql.md#from).|
```
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "edgar2020 (via GitHub)" <gi...@apache.org>.
edgar2020 commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1715631437
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Look up `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null`, when the `expr` is null or when the lookup does not contain a value for `expr`.
Review Comment:
switched "value" -> "key"
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "edgar2020 (via GitHub)" <gi...@apache.org>.
edgar2020 commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1715623788
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Look up `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null`, when the `expr` is null or when the lookup does not contain a value for `expr`.
-**Function type:** [Scalar, string](sql-scalar.md#string-functions)
+* **Syntax:** `LOOKUP(expr, lookupName[, replaceMissingValueWith])`
+* **Function type:** Scalar, string
+
+<details><summary>Example</summary>
+
+The following example uses a map lookup table, named `acronym_to_name` made with the following key-value pairs:
+
+```json
+{
+ “SJU”: Luis Munoz Marin International Airport”,
+ “IAD”: “Dulles International AirportDulles International Airport”
+}
+```
+
+The example uses `acronym_to_name` to map the `Origin` column from the `flight-carriers` datasource to its full airport name. Returns `NaN` if no matching value exist in the lookup table.
Review Comment:
In retrospect probably non, I could change it to "NULL" or "key not found"
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "ektravel (via GitHub)" <gi...@apache.org>.
ektravel commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1712349117
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Look up `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null`, when the `expr` is null or when the lookup does not contain a value for `expr`.
Review Comment:
Other examples use third-person singular form of the verb in simple present tense (a mouthful). "Looks up" doesn't sound great. Maybe "searches for" is a better choice?
```suggestion
Searches for `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null` if `expr` is null or if the lookup doesn't contain a value for `expr`.
```
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "edgar2020 (via GitHub)" <gi...@apache.org>.
edgar2020 commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1715623788
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Look up `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null`, when the `expr` is null or when the lookup does not contain a value for `expr`.
-**Function type:** [Scalar, string](sql-scalar.md#string-functions)
+* **Syntax:** `LOOKUP(expr, lookupName[, replaceMissingValueWith])`
+* **Function type:** Scalar, string
+
+<details><summary>Example</summary>
+
+The following example uses a map lookup table, named `acronym_to_name` made with the following key-value pairs:
+
+```json
+{
+ “SJU”: Luis Munoz Marin International Airport”,
+ “IAD”: “Dulles International AirportDulles International Airport”
+}
+```
+
+The example uses `acronym_to_name` to map the `Origin` column from the `flight-carriers` datasource to its full airport name. Returns `NaN` if no matching value exist in the lookup table.
Review Comment:
In retrospect probably non, I could change it to "NULL"
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "techdocsmith (via GitHub)" <gi...@apache.org>.
techdocsmith merged PR #16878:
URL: https://github.com/apache/druid/pull/16878
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "edgar2020 (via GitHub)" <gi...@apache.org>.
edgar2020 commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1717313489
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Searches for `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null` if `expr` is null or if the lookup doesn't contain a key for `expr`.
Review Comment:
Table description is just introducing the table that is being used, not how it is being used, I do not think it is necessary to update it
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "vtlim (via GitHub)" <gi...@apache.org>.
vtlim commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1717249123
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Searches for `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null` if `expr` is null or if the lookup doesn't contain a key for `expr`.
Review Comment:
Let's move the conditional to the start of the sentence so it doesn't look like the expected return behavior.
```suggestion
Searches for `expr` in a registered [query-time lookup table](lookups.md) named `lookupName` and returns the mapped value. If `expr` is null or not contained in the lookup, returns `replaceMissingValueWith` if supplied, otherwise null.
```
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Searches for `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null` if `expr` is null or if the lookup doesn't contain a key for `expr`.
-**Function type:** [Scalar, string](sql-scalar.md#string-functions)
+* **Syntax:** `LOOKUP(expr, lookupName[, replaceMissingValueWith])`
+* **Function type:** Scalar, string
+
+<details><summary>Example</summary>
+
+The following example uses a `map`-typed lookup table named `acronym_to_name`, made with the following key-value pairs:
Review Comment:
```suggestion
The following example uses a `map`-typed lookup table named `acronym_to_name`, which contains the following key-value pairs:
```
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Searches for `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null` if `expr` is null or if the lookup doesn't contain a key for `expr`.
Review Comment:
Might need to update the table description too? Double check this
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "ektravel (via GitHub)" <gi...@apache.org>.
ektravel commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1712358489
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Look up `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null`, when the `expr` is null or when the lookup does not contain a value for `expr`.
-**Function type:** [Scalar, string](sql-scalar.md#string-functions)
+* **Syntax:** `LOOKUP(expr, lookupName[, replaceMissingValueWith])`
+* **Function type:** Scalar, string
+
+<details><summary>Example</summary>
+
+The following example uses a map lookup table, named `acronym_to_name` made with the following key-value pairs:
Review Comment:
```suggestion
The following example uses a map lookup table named `acronym_to_name`, made with the following key-value pairs:
```
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "techdocsmith (via GitHub)" <gi...@apache.org>.
techdocsmith commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1718792639
##########
docs/querying/sql-functions.md:
##########
@@ -1525,11 +1525,42 @@ Returns the following:
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Searches for `expr` in a registered [query-time lookup table](lookups.md) named `lookupName` and returns the mapped value. If `expr` is null or not contained in the lookup, returns `replaceMissingValueWith` if supplied, otherwise returns null.
-**Function type:** [Scalar, string](sql-scalar.md#string-functions)
+* **Syntax:** `LOOKUP(expr, lookupName[, replaceMissingValueWith])`
+* **Function type:** Scalar, string
+
+<details><summary>Example</summary>
+
+The following example uses a `map`-typed lookup table named `acronym_to_name`, which contains the following key-value pairs:
-Looks up the expression in a registered query-time lookup table.
+```json
+{
+ "SJU": "Luis Munoz Marin International Airport",
+ "IAD": "Dulles International AirportDulles International Airport"
Review Comment:
```suggestion
"IAD": "Dulles International Airport"
```
##########
docs/querying/sql-functions.md:
##########
@@ -1525,11 +1525,42 @@ Returns the following:
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Searches for `expr` in a registered [query-time lookup table](lookups.md) named `lookupName` and returns the mapped value. If `expr` is null or not contained in the lookup, returns `replaceMissingValueWith` if supplied, otherwise returns null.
-**Function type:** [Scalar, string](sql-scalar.md#string-functions)
+* **Syntax:** `LOOKUP(expr, lookupName[, replaceMissingValueWith])`
+* **Function type:** Scalar, string
+
+<details><summary>Example</summary>
+
+The following example uses a `map`-typed lookup table named `acronym_to_name`, which contains the following key-value pairs:
Review Comment:
```suggestion
The following example uses a `map` type lookup table named `acronym_to_name`, which contains the following key-value pairs:
```
hyphenated construction unnecessary
##########
docs/querying/sql-scalar.md:
##########
@@ -102,7 +102,7 @@ String functions accept strings and return a type appropriate to the function.
|`CHAR_LENGTH(expr)`|Alias for `LENGTH`.|
|`CHARACTER_LENGTH(expr)`|Alias for `LENGTH`.|
|`STRLEN(expr)`|Alias for `LENGTH`.|
-|`LOOKUP(expr, lookupName[, replaceMissingValueWith])`|Looks up `expr` in an existing [query-time lookup table](lookups.md) that has the name `lookupName`. Returns the optional constant `replaceMissingValueWith` when `expr` is null or when the lookup does not contain a value for `expr`.<br /><br />You can query lookups directly using the [`lookup` schema](sql.md#from).|
+|`LOOKUP(expr, lookupName[, replaceMissingValueWith])`|Look up `expr` in a registered [query-time lookup table](lookups.md) named `lookupName` and returns the mapped value. If `expr` is null or not contained in the lookup, returns `replaceMissingValueWith` if supplied, otherwise returns null.<br /><br />Lookups can also be queried directly using the [`lookup` schema](sql.md#from).|
Review Comment:
```suggestion
|`LOOKUP(expr, lookupName[, replaceMissingValueWith])`|Look up `expr` in a registered [query-time lookup table](lookups.md) named `lookupName` and returns the mapped value. If `expr` is null or not contained in the lookup, returns `replaceMissingValueWith` if supplied, otherwise returns null.<br /><br />You can query lookups directly using the [`lookup` schema](sql.md#from).|
```
avoid passive
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "FrankChen021 (via GitHub)" <gi...@apache.org>.
FrankChen021 commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1719211397
##########
docs/querying/sql-functions.md:
##########
@@ -1525,11 +1525,42 @@ Returns the following:
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Searches for `expr` in a registered [query-time lookup table](lookups.md) named `lookupName` and returns the mapped value. If `expr` is null or not contained in the lookup, returns `replaceMissingValueWith` if supplied, otherwise returns null.
-**Function type:** [Scalar, string](sql-scalar.md#string-functions)
+* **Syntax:** `LOOKUP(expr, lookupName[, replaceMissingValueWith])`
Review Comment:
Can we use the name `defaultValue` for the 3rd parameter? I think it would be easier to understand.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "edgar2020 (via GitHub)" <gi...@apache.org>.
edgar2020 commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1715635504
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Look up `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null`, when the `expr` is null or when the lookup does not contain a value for `expr`.
Review Comment:
Also switched "value" -> "key" on line 1096 for consistency
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "edgar2020 (via GitHub)" <gi...@apache.org>.
edgar2020 commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1717538706
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Searches for `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null` if `expr` is null or if the lookup doesn't contain a key for `expr`.
Review Comment:
Did need to be updated, changes are now live
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "techdocsmith (via GitHub)" <gi...@apache.org>.
techdocsmith commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1725808008
##########
docs/querying/sql-functions.md:
##########
@@ -1525,11 +1525,42 @@ Returns the following:
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Searches for `expr` in a registered [query-time lookup table](lookups.md) named `lookupName` and returns the mapped value. If `expr` is null or not contained in the lookup, returns `defaultValue` if supplied, otherwise returns null.
-**Function type:** [Scalar, string](sql-scalar.md#string-functions)
+* **Syntax:** `LOOKUP(expr, lookupName[, defaultValue])`
+* **Function type:** Scalar, string
+
+<details><summary>Example</summary>
+
+The following example uses a `map` type lookup table named `acronym_to_name`, which contains the following key-value pairs:
Review Comment:
nit: they are [airport codes](https://www.world-airport-codes.com/) not acronyms
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "ektravel (via GitHub)" <gi...@apache.org>.
ektravel commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1712363546
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Look up `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null`, when the `expr` is null or when the lookup does not contain a value for `expr`.
-**Function type:** [Scalar, string](sql-scalar.md#string-functions)
+* **Syntax:** `LOOKUP(expr, lookupName[, replaceMissingValueWith])`
+* **Function type:** Scalar, string
+
+<details><summary>Example</summary>
+
+The following example uses a map lookup table, named `acronym_to_name` made with the following key-value pairs:
+
+```json
+{
+ “SJU”: Luis Munoz Marin International Airport”,
+ “IAD”: “Dulles International AirportDulles International Airport”
+}
+```
+
+The example uses `acronym_to_name` to map the `Origin` column from the `flight-carriers` datasource to its full airport name. Returns `NaN` if no matching value exist in the lookup table.
Review Comment:
```suggestion
The example uses `acronym_to_name` to map the `Origin` column from the `flight-carriers` datasource to the corresponding full airport name. Returns `NaN` if no matching value exists in the lookup table.
```
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "edgar2020 (via GitHub)" <gi...@apache.org>.
edgar2020 commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1715623788
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Look up `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null`, when the `expr` is null or when the lookup does not contain a value for `expr`.
-**Function type:** [Scalar, string](sql-scalar.md#string-functions)
+* **Syntax:** `LOOKUP(expr, lookupName[, replaceMissingValueWith])`
+* **Function type:** Scalar, string
+
+<details><summary>Example</summary>
+
+The following example uses a map lookup table, named `acronym_to_name` made with the following key-value pairs:
+
+```json
+{
+ “SJU”: Luis Munoz Marin International Airport”,
+ “IAD”: “Dulles International AirportDulles International Airport”
+}
+```
+
+The example uses `acronym_to_name` to map the `Origin` column from the `flight-carriers` datasource to its full airport name. Returns `NaN` if no matching value exist in the lookup table.
Review Comment:
In retrospect probably not, I could change it to "NULL" or "key not found"
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "edgar2020 (via GitHub)" <gi...@apache.org>.
edgar2020 commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1715632988
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Look up `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null`, when the `expr` is null or when the lookup does not contain a value for `expr`.
-**Function type:** [Scalar, string](sql-scalar.md#string-functions)
+* **Syntax:** `LOOKUP(expr, lookupName[, replaceMissingValueWith])`
+* **Function type:** Scalar, string
+
+<details><summary>Example</summary>
+
+The following example uses a map lookup table, named `acronym_to_name` made with the following key-value pairs:
+
+```json
+{
+ “SJU”: Luis Munoz Marin International Airport”,
+ “IAD”: “Dulles International AirportDulles International Airport”
Review Comment:
- [x] Change tabs to spaces
- [x] Used non-stylized quotation marks
- [x] Add missing quotation marks for the first line
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "edgar2020 (via GitHub)" <gi...@apache.org>.
edgar2020 commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1717313489
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Searches for `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null` if `expr` is null or if the lookup doesn't contain a key for `expr`.
Review Comment:
~~Table description is just introducing the table that is being used, not how it is being used, I do not think it is necessary to update it ~~
Was referring to table in sql-scalar.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "vtlim (via GitHub)" <gi...@apache.org>.
vtlim commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1712435381
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Look up `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null`, when the `expr` is null or when the lookup does not contain a value for `expr`.
-**Function type:** [Scalar, string](sql-scalar.md#string-functions)
+* **Syntax:** `LOOKUP(expr, lookupName[, replaceMissingValueWith])`
+* **Function type:** Scalar, string
+
+<details><summary>Example</summary>
+
+The following example uses a map lookup table, named `acronym_to_name` made with the following key-value pairs:
Review Comment:
>map lookup table
`map`-typed lookup
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Look up `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null`, when the `expr` is null or when the lookup does not contain a value for `expr`.
-**Function type:** [Scalar, string](sql-scalar.md#string-functions)
+* **Syntax:** `LOOKUP(expr, lookupName[, replaceMissingValueWith])`
+* **Function type:** Scalar, string
+
+<details><summary>Example</summary>
+
+The following example uses a map lookup table, named `acronym_to_name` made with the following key-value pairs:
+
+```json
+{
+ “SJU”: Luis Munoz Marin International Airport”,
+ “IAD”: “Dulles International AirportDulles International Airport”
Review Comment:
Can you update this to
* Change tabs to spaces
* Used non-stylized quotation marks
* Add missing quotation marks for the first line
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Look up `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null`, when the `expr` is null or when the lookup does not contain a value for `expr`.
Review Comment:
>does not contain a value
Change "value" to "key" for more specificity
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] [Docs] Batch09: only `lookup` (druid)
Posted by "vtlim (via GitHub)" <gi...@apache.org>.
vtlim commented on code in PR #16878:
URL: https://github.com/apache/druid/pull/16878#discussion_r1712436591
##########
docs/querying/sql-functions.md:
##########
@@ -1077,11 +1077,42 @@ Calculates the base-10 of the numeric expression.
## LOOKUP
-`LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])`
+Look up `expr` in a registered [query-time lookup table](lookups.md) named `lookupName`. Returns `replaceMissingValueWith`, which defaults to `null`, when the `expr` is null or when the lookup does not contain a value for `expr`.
-**Function type:** [Scalar, string](sql-scalar.md#string-functions)
+* **Syntax:** `LOOKUP(expr, lookupName[, replaceMissingValueWith])`
+* **Function type:** Scalar, string
+
+<details><summary>Example</summary>
+
+The following example uses a map lookup table, named `acronym_to_name` made with the following key-value pairs:
+
+```json
+{
+ “SJU”: Luis Munoz Marin International Airport”,
+ “IAD”: “Dulles International AirportDulles International Airport”
+}
+```
+
+The example uses `acronym_to_name` to map the `Origin` column from the `flight-carriers` datasource to its full airport name. Returns `NaN` if no matching value exist in the lookup table.
Review Comment:
Is `NaN` a good default value to use, when each lookup key-value pair is already not a number?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org