public Boolean visitConvertExpression()

in contrib/storage-druid/src/main/java/org/apache/drill/exec/store/druid/DruidCompareFunctionProcessor.java [113:177]


  public Boolean visitConvertExpression(ConvertExpression e,
                                        LogicalExpression valueArg) throws RuntimeException {
    if (e.getConvertFunction().equals(ConvertExpression.CONVERT_FROM)
      && e.getInput() instanceof SchemaPath) {
      String encodingType = e.getEncodingType();
      switch (encodingType) {
        case "INT_BE":
        case "INT":
        case "UINT_BE":
        case "UINT":
        case "UINT4_BE":
        case "UINT4":
          if (valueArg instanceof IntExpression
            && (isEqualityFn || encodingType.startsWith("U"))) {
            this.value = ((IntExpression) valueArg).getInt();
          }
          break;
        case "BIGINT_BE":
        case "BIGINT":
        case "UINT8_BE":
        case "UINT8":
          if (valueArg instanceof LongExpression
            && (isEqualityFn || encodingType.startsWith("U"))) {
            this.value = ((LongExpression) valueArg).getLong();
          }
          break;
        case "FLOAT":
          if (valueArg instanceof FloatExpression && isEqualityFn) {
            this.value = ((FloatExpression) valueArg).getFloat();
          }
          break;
        case "DOUBLE":
          if (valueArg instanceof DoubleExpression && isEqualityFn) {
            this.value = ((DoubleExpression) valueArg).getDouble();
          }
          break;
        case "TIME_EPOCH":
        case "TIME_EPOCH_BE":
          if (valueArg instanceof TimeExpression) {
            this.value = ((TimeExpression) valueArg).getTime();
          }
          break;
        case "DATE_EPOCH":
        case "DATE_EPOCH_BE":
          if (valueArg instanceof DateExpression) {
            this.value = ((DateExpression) valueArg).getDate();
          }
          break;
        case "BOOLEAN_BYTE":
          if (valueArg instanceof BooleanExpression) {
            this.value = ((BooleanExpression) valueArg).getBoolean();
          }
          break;
        case "UTF8":
          // let visitSchemaPath() handle this.
          return e.getInput().accept(this, valueArg);
      }

      if (value != null) {
        this.path = (SchemaPath) e.getInput();
        return true;
      }
    }
    return false;
  }