-
Notifications
You must be signed in to change notification settings - Fork 158
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
Handle timestamp_ntz in delta conversion target #647
Draft
vinishjail97
wants to merge
1
commit into
main
Choose a base branch
from
timestamp-ntz
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+16
−10
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,11 @@ public class DeltaSchemaExtractor { | |
private static final String DELTA_COLUMN_MAPPING_ID = "delta.columnMapping.id"; | ||
private static final String COMMENT = "comment"; | ||
private static final DeltaSchemaExtractor INSTANCE = new DeltaSchemaExtractor(); | ||
// Timestamps in Delta are microsecond precision by default | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does XTable need to handle nanoseconds precision? |
||
private static final Map<InternalSchema.MetadataKey, Object> | ||
DEFAULT_TIMESTAMP_PRECISION_METADATA = | ||
Collections.singletonMap( | ||
InternalSchema.MetadataKey.TIMESTAMP_PRECISION, InternalSchema.MetadataValue.MICROS); | ||
|
||
public static DeltaSchemaExtractor getInstance() { | ||
return INSTANCE; | ||
|
@@ -88,7 +93,6 @@ private DataType convertFieldType(InternalField field) { | |
case INT: | ||
return DataTypes.IntegerType; | ||
case LONG: | ||
case TIMESTAMP_NTZ: | ||
return DataTypes.LongType; | ||
case BYTES: | ||
case FIXED: | ||
|
@@ -102,6 +106,8 @@ private DataType convertFieldType(InternalField field) { | |
return DataTypes.DateType; | ||
case TIMESTAMP: | ||
return DataTypes.TimestampType; | ||
case TIMESTAMP_NTZ: | ||
return DataTypes.TimestampNTZType; | ||
case DOUBLE: | ||
return DataTypes.DoubleType; | ||
case DECIMAL: | ||
|
@@ -206,11 +212,11 @@ private InternalSchema toInternalSchema( | |
break; | ||
case "timestamp": | ||
type = InternalType.TIMESTAMP; | ||
// Timestamps in Delta are microsecond precision by default | ||
metadata = | ||
Collections.singletonMap( | ||
InternalSchema.MetadataKey.TIMESTAMP_PRECISION, | ||
InternalSchema.MetadataValue.MICROS); | ||
metadata = DEFAULT_TIMESTAMP_PRECISION_METADATA; | ||
break; | ||
case "timestamp_ntz": | ||
type = InternalType.TIMESTAMP_NTZ; | ||
metadata = DEFAULT_TIMESTAMP_PRECISION_METADATA; | ||
break; | ||
case "struct": | ||
StructType structType = (StructType) dataType; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle this gracefully by calling the function which upgrades version in delta codebase, this was the pending comment from the previous PR that wasn't addressed.
#428
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change related to
timestamp_ntz
? Increasing themin_reader
version could break certain consumers using old libraries. If it's unrelated, could we create a separate issue for this and perhaps make it configurable?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delta does the automatic version upgrade today based on the schema of the table and other properties, if we call the same function when initializing the delta table it shouldn't break anything.
https://docs.delta.io/2.0.0/versioning.html
When creating a table, Delta Lake chooses the minimum required protocol version based on table characteristics such as the schema or table properties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pointers.
However, I believe this change will force an upgrade to the
min_reader
version, even if none of the table features require it. I support updating the version, but lets not mix it in this PR unless it is needed for timezone handling.