use of org.apache.calcite.sql.type.IntervalSqlType in project calcite by apache.
the class SqlDatetimePlusOperator method inferReturnType.
// ~ Methods ----------------------------------------------------------------
@Override
public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
final RelDataType leftType = opBinding.getOperandType(0);
final IntervalSqlType unitType = (IntervalSqlType) opBinding.getOperandType(1);
switch(unitType.getIntervalQualifier().getStartUnit()) {
case HOUR:
case MINUTE:
case SECOND:
case MILLISECOND:
case MICROSECOND:
return typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.TIMESTAMP), leftType.isNullable() || unitType.isNullable());
default:
return leftType;
}
}
Aggregations