FrankChen021 commented on issue #12695:
URL: https://github.com/apache/druid/issues/12695#issuecomment-1177008559
Hi @clintropolis , Introducing JSON type is a very big movement in an
analytic database, and appreciate your const effort on this.
I get some personal opinions on the SQL function level that I want to share
with you.
1. When using `json_value` function to extract a value, this function does
not know what the actual type of the value in advance and maybe there might be
some problems. For example,
```sql
SELECT json_value(a_json_column, "a") / 5
```
In this example, a type of `LONG` or `DOUBLE` is expected for the returning
of json_value function. But If one row accidentally stores the `a` in type of
`STRING`(It's very common because some JSON serialization tools serialize LONG
and DOUBLE as quoted format which will be recognised as string by some other
deserialization tools), above expression fails to calculate.
Or for
```sql
SELECT json_value(a_json_column, "b") + json_value(a_json_column, "c")
```
does it perform a math calculation or string concatenation? It's not clear,
only the writer of the SQL knows.
I think a better way is to make the `json_value` function more specific,
such as `json_value_long`, `json_value_double` and `json_value_string`.
2. I don't know if `json_value` and `json_query` are the final SQL function
names in your implementation, but I think they're a little confusion for people
when they first touch these functions. `json_extract` is a more widely used
function name in other database like MySQL, SQLite, ClickHouse etc, I think we
can use it so people are easy to know what these functions do.
So, I would like to propose the function names as: `json_extract_long`,
`json_extract_double`, `json_extract_string`, `json_extract_object`.
3. The final one is about the performance of application of JSONPath in
above functions. There is a PR(#11467) compares the JSONPath-based
implementation and a hand-writing implementation which turns out the latter one
has much better performance. I'm not saying this hand-writing implementation
should be used but just want to give you a hint.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]