[
https://issues.apache.org/jira/browse/CALCITE-7337?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18045721#comment-18045721
]
Zhen Chen commented on CALCITE-7337:
------------------------------------
|{{age}} ( {{{}timestamp{}}}, {{timestamp}} ) → {{interval}}
Subtract arguments, producing a “symbolic” result that uses years and months,
rather than just days
{{age(timestamp '2001-04-10', timestamp '1957-06-13')}} → {{43 years 9 mons 27
days}}|
|{{age}} ( {{timestamp}} ) → {{interval}}
Subtract argument from {{current_date}} (at midnight)
{{age(timestamp '1957-06-13')}} → {{62 years 6 mons 10 days}}|
I noticed in the documentation that the `age` parameter can have one or two
parameters, two different cases. Are you planning to implement only one? Would
you support a single parameter? I think it would be clearer if you created a
documentation for the Calcite age function that mimics the table format in
PostgreSQL.
PS: If this is your first time contributing to the Calcite community, it might
seem a little demanding, but everyone in the community is very willing to help.
The Calcite community places great emphasis on documentation and code style,
which is very helpful for newcomers to quickly understand each change. Please
feel free to ask any questions.
> There is no age function that supports pgSQL
> --------------------------------------------
>
> Key: CALCITE-7337
> URL: https://issues.apache.org/jira/browse/CALCITE-7337
> Project: Calcite
> Issue Type: New Feature
> Components: core
> Affects Versions: 1.41.0
> Reporter: terran2010
> Priority: Major
> Labels: pull-request-available
>
> The SQL:
> {code:java}
> SELECT AGE(timestamp '2023-12-25', timestamp '2020-01-01') as age1 FROM
> (VALUES (1)) t {code}
> result is ok:
> {code:java}
> 3 years 11 mons 24 days 0 hours 0 mins 0.0 secs {code}
> But is:
> {code:java}
> Error while executing SQL "SELECT AGE(timestamp '2023-12-25', timestamp
> '2020-01-01') as age1 FROM (VALUES (1)) t": From line 1, column 8 to line 1,
> column 58: No match found for function signature AGE(<TIMESTAMP>,
> <TIMESTAMP>) {code}
> we can refer postgresql document about Position:
> [https://www.postgresql.org/docs/current/functions-datetime.html]
> In pgSQL, execute the following
> {code:java}
> SELECT AGE(timestamp '2023-12-25', timestamp '2020-01-01') as age1 FROM
> (VALUES (1)) t; {code}
> result:
> {code:java}
> 3 years 11 mons 24 days 0 hours 0 mins 0.0 secs {code}
> We can consider adding this function to help us use it more conveniently in
> computing time scenarios
--
This message was sent by Atlassian Jira
(v8.20.10#820010)