SQL Query Regular Expression

classic Classic list List threaded Threaded
3 messages Options
fluffy fluffy
Reply | Threaded
Open this post in threaded view
|

SQL Query Regular Expression

Does anyone know what the Ignite capabilities are regarding SQL and Regular Expressions?

Specifically, I am trying to do an SQLFieldQuery based on 2 fields where I would like the text to start with a sequence of characters. In regular SQL speak, this can be done using the '^' character at the beginning of the regular expression.

However, I tried putting the '^' character in my SQLFieldQuery as well as in the setArgs() method, but neither seemed to work.

Does anyone have more detailed on Ignite Regular Expressions?

Thanks much,
Florian
alexey.goncharuk alexey.goncharuk
Reply | Threaded
Open this post in threaded view
|

Re: SQL Query Regular Expression

SQL grammar and limitations are fully defined by the H2 SQL rules as Ignite uses H2 as the underlying SQL engine: http://www.h2database.com/html/grammar.html#condition

For your case something like "SELECT * FORM Table WHERE column REGEXP '^abc' " should work. The documentation says that regular java Matcher.find rules are applied. Note, though, that indexes most likely will not be involved in such a query (this is just my speculation, maybe Sergi can shed more light on this). 
However, for your case the following query will also work: "SELECT * FORM Table WHERE column LIKE 'abc%' ". Such syntax allows to do less than regexp, but this query should be able to pick up an index.

Finally, if neither of the above works for you, you can plug a custom SQL function with @QuerySqlFunction annotation and do whatever filtering you want.

Hope this helps,
AG

2015-06-16 13:47 GMT-07:00 fluffy <[hidden email]>:
Does anyone know what the Ignite capabilities are regarding SQL and Regular
Expressions?

Specifically, I am trying to do an SQLFieldQuery based on 2 fields where I
would like the text to start with a sequence of characters. In regular SQL
speak, this can be done using the '^' character at the beginning of the
regular expression.

However, I tried putting the '^' character in my SQLFieldQuery as well as in
the setArgs() method, but neither seemed to work.

Does anyone have more detailed on Ignite Regular Expressions?

Thanks much,
Florian



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/SQL-Query-Regular-Expression-tp505.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

fluffy fluffy
Reply | Threaded
Open this post in threaded view
|

Re: SQL Query Regular Expression

Thanks Alexey, that was exactly what I was looking for....