添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL translator incorrectly translates this query:

SELECT date_part('century',TIMESTAMP '2017-01-01')

Parser output:

Unknown function: [1:18] SELECT date_part([*]'century',TIMESTAMP '2017-01-01')

P.S.: PostgreSQL dialect
P.P.S.: great initiative, thank you!

I forgot to mention, note that you can easily extend the parser to add support for custom functions, as well as provide implementations / translations for them as shown here:
https://www.jooq.org/doc/latest/manual/sql-building/sql-parser/sql-parser-listener/

Unlike standard SQL EXTRACT , this function allows for using dynamic date part expressions. E.g. this is possible:

select date_part('mont' || c, now())
from (values ('h')) as t(c)

jOOQ won't go as far as support this. I.e. we will not add a new DatePart type in our expression tree model. This will purely be a parser feature, and we'll only support string literals as the first argument, for now. That way, we can at least support what you're doing.

Notice, your TIMESTAMP literal also does not parse yet. I'll address this in a separate issue: #13786