Class DruidExpressions


public class DruidExpressions extends Object
Expression utility class to transform Calcite expressions to Druid expressions when possible.
  • Method Details

    • toDruidExpression

      public static @Nullable String toDruidExpression(RexNode rexNode, RelDataType inputRowType, DruidQuery druidRel)
      Translates a Calcite RexNode to a Druid expression, if possible; returns null if not possible.
      rexNode - RexNode to convert to a Druid Expression
      inputRowType - Input row type of the rexNode to translate
      druidRel - Druid query
      Druid Expression, or null when can not convert the RexNode
    • fromColumn

      public static String fromColumn(String columnName)
    • nullLiteral

      public static String nullLiteral()
    • numberLiteral

      public static String numberLiteral(Number n)
    • stringLiteral

      public static String stringLiteral(String s)
    • functionCall

      public static String functionCall(String functionName, List<String> args)
    • nAryOperatorCall

      public static String nAryOperatorCall(String druidOperator, List<String> args)
    • toDruidExpressions

      public static @Nullable List<String> toDruidExpressions(DruidQuery druidRel, RelDataType rowType, List<RexNode> rexNodes)
      Translate a list of Calcite RexNode to Druid expressions.
      rexNodes - list of Calcite expressions meant to be applied on top of the rows
      list of Druid expressions in the same order as rexNodes, or null if not possible. If a non-null list is returned, all elements will be non-null.
    • applyTimestampFloor

      public static String applyTimestampFloor(String input, String granularity, String origin, TimeZone timeZone)
    • applyTimestampCeil

      public static String applyTimestampCeil(String input, String granularity, String origin, TimeZone timeZone)
    • applyTimeExtract

      public static String applyTimeExtract(String timeExpression, String druidUnit, TimeZone timeZone)