sql/src/main/java/org/apache/druid/sql/calcite/planner/Calcites.java
/**
   * Creates a Calcite TIMESTAMP literal from a Joda DateTime.
   *
   * @param dateTime        joda timestamp
   * @param sessionTimeZone session time zone
   *
   * @return Calcite style Calendar, appropriate for literals
   */
Creates a Calcite TIMESTAMP literal from a Joda DateTime.
@param dateTime        joda timestamp
@param sessionTimeZone session time zone

@return Calcite style Calendar, appropriate for literals
Creates a Calcite TIMESTAMP literal from a Joda DateTime . @param dateTime joda timestamp @param sessionTimeZone session time zone @return Calcite style Calendar appropriate for literals
public static RexLiteral jodaToCalciteTimestampLiteral(
      final RexBuilder rexBuilder,
      final DateTime dateTime,
      final DateTimeZone sessionTimeZone,
      final int precision
  )
  {
    final String timestampString = TRAILING_ZEROS
        .matcher(CALCITE_TIMESTAMP_PRINTER.print(dateTime.withZone(sessionTimeZone)))
        .replaceAll("");
    return rexBuilder.makeTimestampLiteral(new TimestampString(timestampString), precision);
  }
public static RexLiteral jodaToCalciteTimestampLiteral ( final RexBuilder rexBuilder , final DateTime dateTime , final DateTimeZone sessionTimeZone , final int precision ) { final String timestampString = TRAILING_ZEROS . matcher ( CALCITE_TIMESTAMP_PRINTER . print ( dateTime . withZone ( sessionTimeZone ) ) ) . replaceAll ( "" ) ; return rexBuilder . makeTimestampLiteral ( new TimestampString ( timestampString ) , precision ) ; }
Creates a Calcite TIMESTAMP literal from a Joda DateTime.
Creates a Calcite TIMESTAMP literal from a Joda DateTime .
// Calcite expects TIMESTAMP literals to be represented by TimestampStrings in the session time zone. // The TRAILING_ZEROS ... replaceAll is because Calcite doesn't like trailing zeroes in its fractional seconds part.