Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Java8 time objects #2752

Merged
merged 6 commits into from
Mar 27, 2024
Merged

Support Java8 time objects #2752

merged 6 commits into from
Mar 27, 2024

Conversation

yhosny
Copy link
Contributor

@yhosny yhosny commented Mar 14, 2024

Which Delta project/connector is this regarding?

  • Spark
  • Standalone
  • Flink
  • Kernel
  • Other (fill in here)

Description

Added support for Java8 time objects when Java8Api is enabled.

The following query fails when Java8Api is enabled:

INSERT INTO $tableName REPLACE
       where (DATE IN (DATE('2024-03-11'), DATE('2024-03-12')))
       VALUES ('1', DATE('2024-03-13'))

How was this patch tested?

Unit Test.

Does this PR introduce any user-facing changes?

The potential public surface area for this change is limited to only external DateType, TimestampType. By default, Spark converts DateType values to java.sql.Date, TimestampType -> java.sql.Timestamp but with the SQL conf enabled, Spark uses java.time.LocalDate as the external type for DateType and java.time.Instant for TimestampType.

Necessity of fix: If users use Spark 3.0 and enable Java 8, they will be unable to parse and use dates in Delta tables correctly, leading to matching errors.

@yhosny yhosny requested a review from sandip-db March 15, 2024 22:14
Copy link
Contributor

@sandip-db sandip-db left a comment

Choose a reason for hiding this comment

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

test cannot have the same name

@@ -1607,6 +1607,37 @@ class DeltaSuite extends QueryTest
}
}

test("support Java8 time object") {
withSQLConf(SQLConf.DATETIME_JAVA8API_ENABLED.key -> "true") {
Copy link
Contributor

@tdas tdas Mar 18, 2024

Choose a reason for hiding this comment

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

can you give me a reference for this in Spark code? I want to understand how this is tested in Spark.

Copy link
Contributor

@tdas tdas left a comment

Choose a reason for hiding this comment

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

I would like to see a bit more information about the Java8 APIs from the Spark stuff before expanding public API support.

I dont agree with your description that this does not change public API completely. Its quite possible that this SQL conf will be enable in Spark by default. That would implicitly allow new SQL operations in Delta that would have failed earlier. So I do want to understand the public API surface area before I approve this.

@yhosny yhosny requested a review from tdas March 20, 2024 16:32
@tdas tdas merged commit 10edc9c into delta-io:master Mar 27, 2024
7 checks passed
@yhosny
Copy link
Contributor Author

yhosny commented Mar 27, 2024

I would like to see a bit more information about the Java8 APIs from the Spark stuff before expanding public API support.

I dont agree with your description that this does not change public API completely. Its quite possible that this SQL conf will be enable in Spark by default. That would implicitly allow new SQL operations in Delta that would have failed earlier. So I do want to understand the public API surface area before I approve this.

Summarizing offline conversation:

  • The potential public-facing surface area of the fix: The potential public surface area for this change is limited to only one external DateType. By default, Spark converts DateType values to java.sql.Date, but with the SQL conf enabled, Spark uses java.time.LocalDate as the external type for DateType.
  • The necessity of the fix: If users use Spark 3.0 and enable Java 8, they will be unable to parse and use dates in Delta tables correctly, leading to matching errors.
  • The availability: This fix would be available from Spark 3.0 onwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants