Marcos Maia
01/02/2025, 9:54 AMCOMPLEXTYPE<serializablePairLongString>
I have a table definition in Apache Druid with a column as a complex type COMPLEX<serializablePairLongString> created by an ingestion aggregation. So the column data result is displayed like:
Pair{lhs= 1735467541688,rhs=90989.034}
Which is correct as it displays the timestamp and the value as Long/String pairs.
When querying such data I would like to have Druid parse the value and return only the rhs value which is, in this case: 90989.034 , so I don't have to extract it on the application side which is inefficient. I managed to get that using a REGEX from druid on query time like:
REGEXP_EXTRACT(earliest("open"), '(?<=rhs=)([\d.]+)') as op,
which is ok but I wonder if there's a better way since I see operators for JSON for example. Is there an official operator to get this done without using the REGEX? I am assuming if such operator exists that it would be more efficient than using a regex pattern match.
Please let me know.John Kowtko
01/02/2025, 4:18 PMfinalizeAggregations: true
to see if that does it.
If not, then I don't know of a specific function to extract the rhs value from an lhs/rhs pair ... however you could try something like this:
with tmp as (select 'Pair{lhs= 1735467541688,rhs=90989.034}' val)
select val, rtrim(substring(val, strpos(val,'rhs=')+4),'}')
from tmp
It's not pretty ... but it doesn't use Regex so I imagine should process much faster.Laksh Singla
01/06/2025, 7:30 AMMarcos Maia
01/06/2025, 1:47 PMMarcos Maia
01/06/2025, 2:04 PMJohn Kowtko
01/06/2025, 2:37 PMMarcos Maia
01/06/2025, 3:12 PM