Thank you Julian for your reply. I have been thinking about this seriously recently and I have another question. The current date function calculation of calcite convert the parameters, such as date or timestamp, convert to int or long types, finally use the logic of operators such as SqlStdOperatorTable.PLUS to perform the calculation?
Is my guess correct? Best wishes, Cancai Cai > 2024年8月27日 05:11,Norman Jordan <norman.jor...@improving.com.INVALID> 写道: > > Looking into this further, there is this convertlet that will convert a > TIMESTAMP_ADD to a DATETIME_PLUS. > https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java#L2132 > > As part of it, it will convert the amount to add to a unit for DATETIME_PLUS. > For example, hours are converted to milliseconds. > > From there it looks like it will convert this to a "+" operation. > https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java#L3718 > > I didn't see where it adds the two numbers together though. > ________________________________ > From: Cancai Cai <caic68...@gmail.com> > Sent: Monday, August 26, 2024 8:37 AM > To: dev@calcite.apache.org <dev@calcite.apache.org> > Subject: Re: Some doubts about date functions > > Thanks for your reply. > > Yes, I also located here, and I finally debugged to > https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java#L3802 > but I don’t know how to continue. > > I find it hard to believe that > https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/util/BuiltInMethod.java#L517 > is the processing of the data_add function, because its name is add_months > not date_add > >> 2024年8月26日 23:19,Norman Jordan <norman.jor...@improving.com.INVALID> 写道: >> >> this leads to here: >> https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/util/BuiltInMethod.java#L517 >> [https://opengraph.githubassets.com/6af4884a9b80dd1ac5b81e610caea8c9e34bcc847d0e172706a503b58f4f1557/apache/calcite]<https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/util/BuiltInMethod.java#L517> >> calcite/core/src/main/java/org/apache/calcite/util/BuiltInMethod.java at >> main ・ > > Warning: The sender of this message could not be validated and may not be the > actual sender.