[ 
https://issues.apache.org/jira/browse/CALCITE-5183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17551092#comment-17551092
 ] 

Benchao Li commented on CALCITE-5183:
-------------------------------------

{{SqlIntervalQualifier}} can be constructed manually, Calcite also used like 
this in {{SqlDatePartFunction}}: 
https://github.com/apache/calcite/blob/4659479a508461921c5b1e3e7c4d09cb745de33e/core/src/main/java/org/apache/calcite/sql/fun/SqlDatePartFunction.java#L68
For example, you can do it like this:
{code:java}
// INTERVAL '1 1' YEAR TO MONTH
SqlIntervalQualifier qualifier = new SqlIntervalQualifier(TimeUnit.YEAR, 
TimeUnit.MONTH, SqlParserPos.ZERO);
rexBuilder.makeIntervalLiteral(BigDecimal.valueOf(13), qualifier);
{code}

However, this is indeed hard to use. And I feel that it is not right to expose 
{{SqlIntervalQualifier}} in {{RelBuilder}} or {{RexBuilder}}. 


> Impossible condition in return type inference for SqlIntervalOperator?
> ----------------------------------------------------------------------
>
>                 Key: CALCITE-5183
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5183
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Steven Talbot
>            Priority: Major
>
> I could be wrong here, but I don't see how to make this work, and I don't see 
> any tests for it being used on the relBuilder side of the fence (where the 
> "impossible" type inference is invoked for me).
>  
> [https://github.com/apache/calcite/commit/03c76a7d2b896042ab417ddc36f1849f874ad3dd#diff-f6836cabfabc14be277e9f7406ab38996aaa45bac86969cecd64189c2fd7c745R57]
>   requires the second argument to the Interval call to be literal wrapper 
> around a SqlIntervalQualifier. In the context of RexCallBinding, I don't 
> believe this is possible, since the argument has to be a RexLiteral, and 
> RexLiteral exposes no way to directly wrap a value as a SqlIntervalQualifier 
> like this. Again, this is where my reading of the code gets uncertain, but 
> neither signature of RexBuilder.makeIntervalLiteral will give you what you 
> want, and I don't see any way this could be possible. 
>  
> This issue means that there seems to be no way to use 
> `SqlStdOperatorTable.INTERVAL` with RelBuilder.call.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to