Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.36.0
Description
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
@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); }
The correct value is readily accessible from
opBinding.getTypeFactory().getTypeSystem().getMaxPrecision(typeName)
Attachments
Issue Links
- links to