[ 
https://issues.apache.org/jira/browse/CALCITE-6262?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mihai Budiu resolved CALCITE-6262.
----------------------------------
    Fix Version/s: 1.37.0
       Resolution: Fixed

Fixed in 
https://github.com/apache/calcite/commit/b0034c9ed885644e22edc92e8ab939128ee6b615
Thank you [~jduong] for the fix

> CURRENT_TIMESTAMP(P) ignores DataTypeSystem#getMaxPrecision
> -----------------------------------------------------------
>
>                 Key: CALCITE-6262
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6262
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.36.0
>            Reporter: Adam Kennedy
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.37.0
>
>
> Datetime precision parameters are incorrectly validated against the DEFAULT 
> maximum date time precision (3) instead of against the maximum date time 
> precision configured by the DateTimeSystem#getMaxPrecision method.
> This breaks, at minimum, CURRENT_TIMESTAMP(P > 3) when precisions greater 
> than 3 are supported by the system.
> The culprit is the following method in SqlAbstractTimeFunction
>  
> {code:java}
> @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
>     // REVIEW jvs 20-Feb-2005: Need to take care of time zones.
>     int precision = 0;
>     if (opBinding.getOperandCount() == 1) {
>         RelDataType type = opBinding.getOperandType(0);
>         if (SqlTypeUtil.isNumeric(type)) {
>             precision = getOperandLiteralValueOrThrow(opBinding, 0, 
> Integer.class);
>         }
>     }
>     assert precision >= 0;
>     if (precision > SqlTypeName.MAX_DATETIME_PRECISION) {
>         throw opBinding.newError(
>             RESOURCE.argumentMustBeValidPrecision(
>             opBinding.getOperator().getName(), 0,
>             SqlTypeName.MAX_DATETIME_PRECISION));
>     }
>     return opBinding.getTypeFactory().createSqlType(typeName, precision);
> }{code}
>  
>  
> The correct value is readily accessible from
>  
> {code:java}
> opBinding.getTypeFactory().getTypeSystem().getMaxPrecision(typeName){code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to