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

    https://github.com/apache/spark/pull/17062#discussion_r103300013
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/HashExpressionsSuite.scala
 ---
    @@ -169,6 +171,96 @@ class HashExpressionsSuite extends SparkFunSuite with 
ExpressionEvalHelper {
         // scalastyle:on nonascii
       }
     
    +  test("hive-hash for date type") {
    +    def checkHiveHashForDateType(dateString: String, expected: Long): Unit 
= {
    +      checkHiveHash(
    +        DateTimeUtils.stringToDate(UTF8String.fromString(dateString)).get,
    +        DateType,
    +        expected)
    +    }
    +
    +    // basic case
    +    checkHiveHashForDateType("2017-01-01", 17167)
    +
    +    // boundary cases
    +    checkHiveHashForDateType("0000-01-01", -719530)
    +    checkHiveHashForDateType("9999-12-31", 2932896)
    +
    +    // epoch
    +    checkHiveHashForDateType("1970-01-01", 0)
    +
    +    // before epoch
    +    checkHiveHashForDateType("1800-01-01", -62091)
    +
    +    // Invalid input: bad date string. Hive returns 0 for such cases
    --- End diff --
    
    Spark does not allow creating `Date` which do not fit its spec and throws 
exception. Hive will not fail but fallback to `null` and return `0` as hash 
value.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to