pinot icon indicating copy to clipboard operation
pinot copied to clipboard

Support extract syntax

Open gortiz opened this issue 3 years ago • 2 comments

SQL defines the extract expression that can be used to access components of temporal datatypes. Calcite already supports it, so when an expression includes an extract function it parses. But once Pinot tries to convert it to its own expression AST, it fails with:

ProcessingException(errorCode:150, message:PQLParsingError:
java.lang.ClassCastException: class org.apache.calcite.sql.SqlIntervalQualifier cannot be cast to class org.apache.calcite.sql.SqlBasicCall (org.apache.calcite.sql.SqlIntervalQualifier and org.apache.calcite.sql.SqlBasicCall are in unnamed module of loader 'app')
	at org.apache.pinot.sql.parsers.CalciteSqlParser.toExpression(CalciteSqlParser.java:682)
	at org.apache.pinot.sql.parsers.CalciteSqlParser.compileFunctionExpression(CalciteSqlParser.java:737)
	at org.apache.pinot.sql.parsers.CalciteSqlParser.toExpression(CalciteSqlParser.java:682)
	at org.apache.pinot.sql.parsers.CalciteSqlParser.toExpression(CalciteSqlParser.java:619))

Pinot already have functions like minute, year, etc so this seems to be a matter of syntax.

gortiz avatar Jul 20 '22 09:07 gortiz

I am planning to pick this up.

tanmesh avatar Aug 01 '22 03:08 tanmesh

I have added the progress so far in the above PR. May I get some eyes on this, to ensure that I am on the right track?

tanmesh avatar Aug 09 '22 16:08 tanmesh

@npawar Update -- PR is merged.

tanmesh avatar Sep 15 '22 23:09 tanmesh

@tanmesh Can you help also update this document page: https://docs.pinot.apache.org/users/user-guide-query/supported-transformations#transform-functions The source code can be found here: https://github.com/pinot-contrib/pinot-docs

Jackie-Jiang avatar Sep 16 '22 18:09 Jackie-Jiang

I have added the documentation in the PR above ^. Please review it.

tanmesh avatar Sep 22 '22 02:09 tanmesh

Merged. Thank you so much for your contribution!

Jackie-Jiang avatar Sep 22 '22 02:09 Jackie-Jiang