You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/12/14 17:04:21 UTC

[GitHub] [druid] ankitnayan opened a new issue #10678: How to store and query array of key value pairs?

ankitnayan opened a new issue #10678:
URL: https://github.com/apache/druid/issues/10678


   My data format is like:
   
   ```
   {
     timestamp string,
     name string,
     kind int,
     status_code int,
     ...
     tags: {
       key1: value1,
       key2: value2,
       ...
     }
   
   }
   ```
   **The list of keys in tags is varying in size for each row and the keys are also not defined (it can be anything string).**
   
   I want to query dataset by tags, i.e., return all rows which have given key: value pair.
   
   In Pinot, we can achieve this by storing all keys in a multi-value dimension TAGS__KEYS and all values in another multi-value dimension TAGS__VALUES and then query using MAP_VALUE function.
   
   Sample query:
   
   ```SELECT * FROM xyzView WHERE ( tags__KEYS = 'key1' AND tags__VALUES = 'value1' AND mapValue(tags__KEYS,'key1',tags__VALUES) = 'value1' )```
   
   How can we achieve the same in Druid? Druid also has a multi-value dimension but does not have mapValue functionality. Or can we achieve this using any other way in Druid?


----------------------------------------------------------------
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.

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


[GitHub] [druid] kociepa commented on issue #10678: How to store and query array of key value pairs?

Posted by GitBox <gi...@apache.org>.
kociepa commented on issue #10678:
URL: https://github.com/apache/druid/issues/10678#issuecomment-792777505


   you can use the js exctraction function to extract keys and values from concatenated pairs ( https://druid.apache.org/docs/latest/querying/dimensionspecs.html#javascript-extraction-function ). So either in filters or in grouping you can use the exctraction function


----------------------------------------------------------------
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.

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


[GitHub] [druid] chrisociepa commented on issue #10678: How to store and query array of key value pairs?

Posted by GitBox <gi...@apache.org>.
chrisociepa commented on issue #10678:
URL: https://github.com/apache/druid/issues/10678#issuecomment-792778021


   you can use the js exctraction function to extract keys and values from concatenated pairs ( https://druid.apache.org/docs/latest/querying/dimensionspecs.html#javascript-extraction-function ). So either in filters or in grouping you can use the exctraction function


----------------------------------------------------------------
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.

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


[GitHub] [druid] himanshug commented on issue #10678: How to store and query array of key value pairs?

Posted by GitBox <gi...@apache.org>.
himanshug commented on issue #10678:
URL: https://github.com/apache/druid/issues/10678#issuecomment-793057071


   most common approach to handle that in Druid is to flatten the schema during/before ingestion so that in the end Druid datasource columns are [timestamp, name, kind, status_code, key1, key2,..] .
   Then there are no problems on query side.


----------------------------------------------------------------
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.

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


[GitHub] [druid] ankitnayan commented on issue #10678: How to store and query array of key value pairs?

Posted by GitBox <gi...@apache.org>.
ankitnayan commented on issue #10678:
URL: https://github.com/apache/druid/issues/10678#issuecomment-793465541


   This seems interesting. So, it will keep updating the schema as it ingests events with new keys? Let me give it a try


----------------------------------------------------------------
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.

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


[GitHub] [druid] kociepa removed a comment on issue #10678: How to store and query array of key value pairs?

Posted by GitBox <gi...@apache.org>.
kociepa removed a comment on issue #10678:
URL: https://github.com/apache/druid/issues/10678#issuecomment-792777505


   you can use the js exctraction function to extract keys and values from concatenated pairs ( https://druid.apache.org/docs/latest/querying/dimensionspecs.html#javascript-extraction-function ). So either in filters or in grouping you can use the exctraction function


----------------------------------------------------------------
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.

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


[GitHub] [druid] himanshug commented on issue #10678: How to store and query array of key value pairs?

Posted by GitBox <gi...@apache.org>.
himanshug commented on issue #10678:
URL: https://github.com/apache/druid/issues/10678#issuecomment-793454582


   > @himanshug But the number of keys and the keys themselves are not fixed. It varies for every event.
   
   that is fine, Druid ingestion has a mode where it "discovers" the dimensions and that would be appropriate for this use case. In the end, when segment is built it will have list-of-dimensions = union-of(dimensions in all events)
   
   quoting from  https://druid.apache.org/docs/latest/ingestion/index.html#dimensionsspec
   "If this and spatialDimensions are both null or empty arrays, Druid will treat all non-timestamp, non-metric columns that do not appear in dimensionExclusions as String-typed dimension columns. See inclusions and exclusions below for details."


----------------------------------------------------------------
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.

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


[GitHub] [druid] ankitnayan commented on issue #10678: How to store and query array of key value pairs?

Posted by GitBox <gi...@apache.org>.
ankitnayan commented on issue #10678:
URL: https://github.com/apache/druid/issues/10678#issuecomment-793421363


   @himanshug But the number of keys and the keys themselves are not fixed. It varies for every event. 


----------------------------------------------------------------
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.

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


[GitHub] [druid] ankitnayan commented on issue #10678: How to store and query array of key value pairs?

Posted by GitBox <gi...@apache.org>.
ankitnayan commented on issue #10678:
URL: https://github.com/apache/druid/issues/10678#issuecomment-792688625


   @chrisociepa Can you please detail down? I have TAGS__KEYS and TAGS__VALUES as multi-value dimension. Extraction functions, as I saw mostly used regex to match data. Regex won't work in this case Eg, multiple keys can have value `true` but we then won't know which one really did. Or am I missing something?


----------------------------------------------------------------
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.

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


[GitHub] [druid] chrisociepa commented on issue #10678: How to store and query array of key value pairs?

Posted by GitBox <gi...@apache.org>.
chrisociepa commented on issue #10678:
URL: https://github.com/apache/druid/issues/10678#issuecomment-752004402


   you can store `tags` as an array of concatenated `KEY__VALUE` and use an extraction function ( https://druid.apache.org/docs/latest/querying/dimensionspecs.html#extraction-functions ) in your query filter


----------------------------------------------------------------
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.

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