Ejemplo n.º 1
0
 public static Signature comparisonExpressionSignature(
     ComparisonExpression.Type expressionType, Type leftType, Type rightType) {
   for (OperatorType operatorType : OperatorType.values()) {
     if (operatorType.name().equals(expressionType.name())) {
       return internalOperator(
           expressionType.name(),
           parseTypeSignature(StandardTypes.BOOLEAN),
           leftType.getTypeSignature(),
           rightType.getTypeSignature());
     }
   }
   return internalFunction(
       expressionType.name(),
       parseTypeSignature(StandardTypes.BOOLEAN),
       leftType.getTypeSignature(),
       rightType.getTypeSignature());
 }
  @Test
  public void testComparisonExpressionWithNulls() {
    for (ComparisonExpression.Type type : ComparisonExpression.Type.values()) {
      if (type == ComparisonExpression.Type.IS_DISTINCT_FROM) {
        // IS DISTINCT FROM has different NULL semantics
        continue;
      }

      assertFilter(format("NULL %s NULL", type.getValue()), false);

      assertFilter(format("42 %s NULL", type.getValue()), false);
      assertFilter(format("NULL %s 42", type.getValue()), false);

      assertFilter(format("11.1 %s NULL", type.getValue()), false);
      assertFilter(format("NULL %s 11.1", type.getValue()), false);
    }
  }