Adam Kennedy created CALCITE-6262: ------------------------------------- Summary: 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
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)