linkedin / coral

Coral is a translation, analysis, and query rewrite engine for SQL and other relational languages.
BSD 2-Clause "Simplified" License
795 stars 187 forks source link

Coral transform hive function “regexp_extract” to trino by introduce a new function "hive_pattern_to_trino" #266

Open gjhkael opened 2 years ago

gjhkael commented 2 years ago

Coral transform the following hive sql to trino

select regexp_extract('1a 2b 14m', '\d+', 1); 

result:

select regexp_extract('1a 2b 14m', "hive_pattern_to_presto"('\d+'), 1); 

But trino not have the function name of "hive_pattern_to_presto", then the query will failed with exception:

Function 'hive_pattern_to_trino' not registered

So, why you introduce the "hive_pattern_to_trino" function? Do this function is implement in linkedin internal?

findinpath commented 2 years ago

Related code: https://github.com/linkedin/coral/blob/c96456329efc5eab15393e5c7bfb7e4e009f2245/coral-trino/src/main/java/com/linkedin/coral/trino/rel2trino/UDFTransformer.java#L147-L149