Skip to content

Conversation

@MaxGekk
Copy link
Member

@MaxGekk MaxGekk commented May 25, 2020

What changes were proposed in this pull request?

Convert java.time.Instant to java.sql.Timestamp in pushed down filters to ORC datasource when Java 8 time API enabled.

Why are the changes needed?

The changes fix the exception raised while pushing date filters when spark.sql.datetime.java8API.enabled is set to true:

java.lang.IllegalArgumentException: Wrong value class java.time.Instant for TIMESTAMP.EQUALS leaf
 at org.apache.hadoop.hive.ql.io.sarg.SearchArgumentImpl$PredicateLeafImpl.checkLiteralType(SearchArgumentImpl.java:192)
 at org.apache.hadoop.hive.ql.io.sarg.SearchArgumentImpl$PredicateLeafImpl.<init>(SearchArgumentImpl.java:75)

Does this PR introduce any user-facing change?

Yes

How was this patch tested?

Added tests to OrcFilterSuite.

@MaxGekk
Copy link
Member Author

MaxGekk commented May 25, 2020

@cloud-fan @HyukjinKwon @dongjoon-hyun Please, review this PR. It is similar to #28261 but for timestamps.

implicit def bigDecimalToLiteral(d: java.math.BigDecimal): Literal = Literal(d)
implicit def decimalToLiteral(d: Decimal): Literal = Literal(d)
implicit def timestampToLiteral(t: Timestamp): Literal = Literal(t)
implicit def timestampToLiteral(t: Instant): Literal = Literal(t)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we call it instantToLiteral, to be consistent with localDateToLiteral?

@SparkQA
Copy link

SparkQA commented May 25, 2020

Test build #123084 has finished for PR 28636 at commit 5290d96.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@MaxGekk MaxGekk changed the title [SPARK-31818][SQL][test-hive1.2] Fix pushing down filters with java.time.Instant values in ORC [SPARK-31818][SQL] Fix pushing down filters with java.time.Instant values in ORC May 25, 2020
@MaxGekk
Copy link
Member Author

MaxGekk commented May 25, 2020

jenkins, retest this, please

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM. Thank you for testing both hive profile, @MaxGekk .

@SparkQA
Copy link

SparkQA commented May 25, 2020

Test build #123086 has finished for PR 28636 at commit e24fb31.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

implicit def bigDecimalToLiteral(d: java.math.BigDecimal): Literal = Literal(d)
implicit def decimalToLiteral(d: Decimal): Literal = Literal(d)
implicit def timestampToLiteral(t: Timestamp): Literal = Literal(t)
implicit def instantToLiteral(t: Instant): Literal = Literal(t)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variable name: i instead of t if want follow convention around

@SparkQA
Copy link

SparkQA commented May 25, 2020

Test build #123093 has finished for PR 28636 at commit e24fb31.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented May 26, 2020

Test build #123098 has finished for PR 28636 at commit 2773ceb.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

dongjoon-hyun pushed a commit that referenced this pull request May 26, 2020
…values in ORC

### What changes were proposed in this pull request?
Convert `java.time.Instant` to `java.sql.Timestamp` in pushed down filters to ORC datasource when Java 8 time API enabled.

### Why are the changes needed?
The changes fix the exception raised while pushing date filters when `spark.sql.datetime.java8API.enabled` is set to `true`:
```
java.lang.IllegalArgumentException: Wrong value class java.time.Instant for TIMESTAMP.EQUALS leaf
 at org.apache.hadoop.hive.ql.io.sarg.SearchArgumentImpl$PredicateLeafImpl.checkLiteralType(SearchArgumentImpl.java:192)
 at org.apache.hadoop.hive.ql.io.sarg.SearchArgumentImpl$PredicateLeafImpl.<init>(SearchArgumentImpl.java:75)
```

### Does this PR introduce any user-facing change?
Yes

### How was this patch tested?
Added tests to `OrcFilterSuite`.

Closes #28636 from MaxGekk/orc-timestamp-filter-pushdown.

Authored-by: Max Gekk <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
(cherry picked from commit 6c80ebb)
Signed-off-by: Dongjoon Hyun <[email protected]>
@dongjoon-hyun
Copy link
Member

Merged to master/3.0. Thank you, @MaxGekk , @cloud-fan , @seanli-rallyhealth .

@MaxGekk MaxGekk deleted the orc-timestamp-filter-pushdown branch June 5, 2020 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants