@Nullable @Override public String toDruidExpression(RexNode rexNode, RelDataType rowType, DruidQuery query
    ) {
      final RexCall call = (RexCall) rexNode;
      //can handle only case trunc date type
      if (call.getOperands().size() < 1) {
        throw new IllegalStateException("trunc() requires at least 1 argument, got " + call.getOperands().size());
      }
      if (call.getOperands().size() == 1) {
        final String arg = DruidExpressions.toDruidExpression(call.getOperands().get(0), rowType, query);
        if (arg == null) {
          return null;
        }
        if (SqlTypeUtil.isDatetime(call.getOperands().get(0).getType())) {
          final TimeZone tz = timezoneId(query, call.getOperands().get(0));
          return applyTimestampFormat(
              DruidExpressions.applyTimestampFloor(arg, Period.days(1).toString(), "", tz),
              YYYY_MM_DD,
              tz);
        }
        return null;
      } else if (call.getOperands().size() == 2) {
        final String arg = DruidExpressions.toDruidExpression(call.getOperands().get(0), rowType, query);
        if (arg == null) {
          return null;
        }
        String granularity = DruidExpressions.toDruidExpression(call.getOperands().get(1), rowType, query);
        if (granularity == null) {
          return null;
        }
        final String unit;
        if ("'MONTH'".equals(granularity) || "'MON'".equals(granularity) || "'MM'".equals(granularity)) {
          unit = Period.months(1).toString();
        } else if ("'YEAR'".equals(granularity) || "'YYYY'".equals(granularity) || "'YY'".equals(granularity)) {
          unit = Period.years(1).toString();
        } else if ("'QUARTER'".equals(granularity) || "'Q'".equals(granularity)) {
          unit = Period.months(3).toString();
        } else {
          unit = null;
        }
        if (unit == null) {
          //bail out can not infer unit
          return null;
        }
        final TimeZone tz = timezoneId(query, call.getOperands().get(0));
        return applyTimestampFormat(
            DruidExpressions.applyTimestampFloor(arg, unit, "", tz),
            YYYY_MM_DD,
            tz);
      }
      return null;
    }
Operator conversion form Hive TRUNC UDF to Druid Date Time UDFs.
ql/src/java/org/apache/hadoop/hive/ql/parse/DruidSqlOperatorConverter.java