private static Operand translateFloor()

in calcite-adapter/src/main/java/software/amazon/documentdb/jdbc/calcite/adapter/DocumentDbRules.java [898:930]


        private static Operand translateFloor(final RexCall rexCall, final List<Operand> strings) {
            // TODO: Add support for integer floor with one operand
            if (rexCall.operands.size() != 2) {
                return null;
            }

            // NOTE: Required for getting FLOOR of date-time
            final RexNode operand2 = rexCall.operands.get(1);
            if (!(operand2.isA(SqlKind.LITERAL)
                    && operand2.getType().getSqlTypeName() == SqlTypeName.SYMBOL
                    && (((RexLiteral) operand2).getValue() instanceof TimeUnitRange))) {
                return null;
            }
            final RexLiteral literal = (RexLiteral) operand2;
            final TimeUnitRange timeUnitRange = getValueAs(literal, TimeUnitRange.class);
            switch (timeUnitRange) {
                case YEAR:
                case MONTH:
                    return new Operand(formatYearMonthFloorOperation(strings, timeUnitRange));
                case QUARTER:
                    return new Operand(formatQuarterFloorOperation(strings));
                case WEEK:
                case DAY:
                case HOUR:
                case MINUTE:
                case SECOND:
                case MILLISECOND:
                    return formatMillisecondFloorOperation(strings, timeUnitRange);
                default:
                    throw SqlError.createSQLFeatureNotSupportedException(LOGGER,
                            SqlError.UNSUPPORTED_PROPERTY, timeUnitRange.toString());
            }
        }