You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Danny Chan (JIRA)" <ji...@apache.org> on 2019/03/16 02:48:00 UTC

[jira] [Commented] (CALCITE-2923) MAX_DATETIME_PRECISION limitation

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

Danny Chan commented on CALCITE-2923:
-------------------------------------

In SqlAbstractTimeFunction, you can see the usage of SqlTypeName.MAX_DATETIME_PRECISION:

{code:java}
// 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 = opBinding.getOperandLiteralValue(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));
    }
{code}

LOCALTIME, and LOCALTIMESTAMP can optionally take a precision parameter, which causes the result to be rounded to that many fractional digits in the seconds field. Without a precision parameter, the result is given to the full available precision.

3 is the case [1] [2] [3]

[1]. https://en.wikipedia.org/wiki/Time_zone
[2] https://issues.apache.org/jira/browse/CALCITE-1947
[3] https://www.postgresql.org/docs/9.6/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT

> MAX_DATETIME_PRECISION limitation
> ---------------------------------
>
>                 Key: CALCITE-2923
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2923
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.16.0
>            Reporter: hui
>            Priority: Major
>
> why do you set   MAX_DATETIME_PRECISION = 3 ?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)