Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3367#discussion_r21119345
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/parquet/ParquetQuerySuite.scala ---
    @@ -938,4 +945,104 @@ class ParquetQuerySuite extends QueryTest with 
FunSuiteLike with BeforeAndAfterA
           checkAnswer(parquetFile(tempDir), data.toSchemaRDD.collect().toSeq)
         }
       }
    +
    +  def checkFilter(predicate: Predicate, filterClass: Class[_ <: 
FilterPredicate]): Unit = {
    +    val filter = ParquetFilters.createFilter(predicate)
    +    assert(filter.isDefined)
    +    assert(filter.get.getClass == filterClass)
    +  }
    +
    +  test("Pushdown IsNull predicate") {
    +    checkFilter('a.int.isNull,    classOf[Operators.Eq[Integer]])
    +    checkFilter('a.long.isNull,   classOf[Operators.Eq[java.lang.Long]])
    +    checkFilter('a.float.isNull,  classOf[Operators.Eq[java.lang.Float]])
    +    checkFilter('a.double.isNull, classOf[Operators.Eq[java.lang.Double]])
    +    checkFilter('a.string.isNull, classOf[Operators.Eq[Binary]])
    +    checkFilter('a.binary.isNull, classOf[Operators.Eq[Binary]])
    +  }
    +
    +  test("Pushdown IsNotNull predicate") {
    +    checkFilter('a.int.isNotNull,    classOf[Operators.NotEq[Integer]])
    +    checkFilter('a.long.isNotNull,   
classOf[Operators.NotEq[java.lang.Long]])
    +    checkFilter('a.float.isNotNull,  
classOf[Operators.NotEq[java.lang.Float]])
    +    checkFilter('a.double.isNotNull, 
classOf[Operators.NotEq[java.lang.Double]])
    +    checkFilter('a.string.isNotNull, classOf[Operators.NotEq[Binary]])
    +    checkFilter('a.binary.isNotNull, classOf[Operators.NotEq[Binary]])
    +  }
    +
    +  test("Pushdown EqualTo predicate") {
    +    checkFilter('a.int === 0,                 
classOf[Operators.Eq[Integer]])
    +    checkFilter('a.long === 0.toLong,         
classOf[Operators.Eq[java.lang.Long]])
    +    checkFilter('a.float === 0.toFloat,       
classOf[Operators.Eq[java.lang.Float]])
    +    checkFilter('a.double === 0.toDouble,     
classOf[Operators.Eq[java.lang.Double]])
    +    checkFilter('a.string === "foo",          
classOf[Operators.Eq[Binary]])
    +    checkFilter('a.binary === "foo".getBytes, 
classOf[Operators.Eq[Binary]])
    +  }
    +
    +  test("Pushdown Not(EqualTo) predicate") {
    +    checkFilter(!('a.int === 0),                 
classOf[Operators.NotEq[Integer]])
    +    checkFilter(!('a.long === 0.toLong),         
classOf[Operators.NotEq[java.lang.Long]])
    +    checkFilter(!('a.float === 0.toFloat),       
classOf[Operators.NotEq[java.lang.Float]])
    +    checkFilter(!('a.double === 0.toDouble),     
classOf[Operators.NotEq[java.lang.Double]])
    +    checkFilter(!('a.string === "foo"),          
classOf[Operators.NotEq[Binary]])
    +    checkFilter(!('a.binary === "foo".getBytes), 
classOf[Operators.NotEq[Binary]])
    +  }
    +
    +  test("Pushdown LessThan predicate") {
    +    checkFilter('a.int < 0,                 classOf[Operators.Lt[Integer]])
    +    checkFilter('a.long < 0.toLong,         
classOf[Operators.Lt[java.lang.Long]])
    +    checkFilter('a.float < 0.toFloat,       
classOf[Operators.Lt[java.lang.Float]])
    +    checkFilter('a.double < 0.toDouble,     
classOf[Operators.Lt[java.lang.Double]])
    +    checkFilter('a.string < "foo",          classOf[Operators.Lt[Binary]])
    +    checkFilter('a.binary < "foo".getBytes, classOf[Operators.Lt[Binary]])
    +  }
    +
    +  test("Pushdown LessThanOrEqual predicate") {
    +    checkFilter('a.int <= 0,                 
classOf[Operators.LtEq[Integer]])
    +    checkFilter('a.long <= 0.toLong,         
classOf[Operators.LtEq[java.lang.Long]])
    +    checkFilter('a.float <= 0.toFloat,       
classOf[Operators.LtEq[java.lang.Float]])
    +    checkFilter('a.double <= 0.toDouble,     
classOf[Operators.LtEq[java.lang.Double]])
    +    checkFilter('a.string <= "foo",          
classOf[Operators.LtEq[Binary]])
    +    checkFilter('a.binary <= "foo".getBytes, 
classOf[Operators.LtEq[Binary]])
    +  }
    +
    +  test("Pushdown GreaterThan predicate") {
    +    checkFilter('a.int > 0,                 classOf[Operators.Gt[Integer]])
    +    checkFilter('a.long > 0.toLong,         
classOf[Operators.Gt[java.lang.Long]])
    +    checkFilter('a.float > 0.toFloat,       
classOf[Operators.Gt[java.lang.Float]])
    +    checkFilter('a.double > 0.toDouble,     
classOf[Operators.Gt[java.lang.Double]])
    +    checkFilter('a.string > "foo",          classOf[Operators.Gt[Binary]])
    +    checkFilter('a.binary > "foo".getBytes, classOf[Operators.Gt[Binary]])
    +  }
    +
    +  test("Pushdown GreaterThanOrEqual predicate") {
    +    checkFilter('a.int >= 0,                 
classOf[Operators.GtEq[Integer]])
    +    checkFilter('a.long >= 0.toLong,         
classOf[Operators.GtEq[java.lang.Long]])
    +    checkFilter('a.float >= 0.toFloat,       
classOf[Operators.GtEq[java.lang.Float]])
    +    checkFilter('a.double >= 0.toDouble,     
classOf[Operators.GtEq[java.lang.Double]])
    +    checkFilter('a.string >= "foo",          
classOf[Operators.GtEq[Binary]])
    +    checkFilter('a.binary >= "foo".getBytes, 
classOf[Operators.GtEq[Binary]])
    +  }
    +
    +  test("Comparison with null should not be pushed down") {
    +    val predicates = Seq(
    +      'a.int === null,
    +      !('a.int === null),
    +
    +      Literal(null) === 'a.int,
    +      !(Literal(null) === 'a.int),
    +
    +      'a.int < null,
    +      'a.int <= null,
    +      'a.int > null,
    +      'a.int >= null,
    +
    +      Literal(null) < 'a.int,
    +      Literal(null) <= 'a.int,
    +      Literal(null) > 'a.int,
    +      Literal(null) >= 'a.int
    +    )
    +
    +    predicates.foreach(p => assert(ParquetFilters.createFilter(p).isEmpty))
    --- End diff --
    
    Can you add a string to make the failure message more descriptive?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to