-
Notifications
You must be signed in to change notification settings - Fork 3
Backport to branch(3) : Support time-related data types in generic function #211
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
Conversation
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.
Summary of Changes
Hello @feeblefakie, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
I've backported changes to introduce comprehensive support for time-related data types (DATE, TIME, TIMESTAMP, TIMESTAMPTZ) within the generic contract functions, specifically for operations involving mutable databases. This enhancement allows for more precise and standardized handling of temporal data within the system.
Highlights
- Enhanced Date/Time Handling: I've added new DateTimeFormatter constants in Constants.java to standardize the parsing and formatting of DATE, TIME, TIMESTAMP, and TIMESTAMPTZ literals.
- Schema Evolution: The registered_at field in objects-table-schema.json has been updated from BIGINT to TIMESTAMP, reflecting the improved temporal data storage capabilities.
- Expanded Generic Contract Functionality: The PutToMutableDatabase function now correctly processes and stores DATE, TIME, TIMESTAMP, and TIMESTAMPTZ values, including robust error handling for invalid formats.
- Comprehensive Test Coverage: I've introduced new integration and unit tests to validate the proper handling of these new time-related data types, ensuring their correct behavior and error detection.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request backports support for time-related data types in the generic function contract. The changes are well-implemented and include new DateTimeFormatter
constants, updates to the database schema, and modifications in the contract logic to handle DATE
, TIME
, TIMESTAMP
, and TIMESTAMPTZ
data types. The accompanying tests are thorough. I've identified a few areas for improvement related to code consistency, quality, and removing dead/unreachable code. My suggestions aim to make the code more robust and maintainable.
.appendValue(SECOND_OF_MINUTE, 2) | ||
.optionalStart() | ||
.appendFraction(NANO_OF_SECOND, 0, 3, true) | ||
.toFormatter(); |
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.
For consistency with DATE_FORMATTER
and TIME_FORMATTER
, and to ensure strict parsing, TIMESTAMP_FORMATTER
should be configured with ResolverStyle.STRICT
and IsoChronology.INSTANCE
. The current implementation uses the default SMART
resolver style, which might lead to lenient parsing of invalid timestamp strings.
.toFormatter()
.withResolverStyle(ResolverStyle.STRICT)
.withChronology(IsoChronology.INSTANCE);
.toFormatter() | ||
.withZone(ZoneOffset.UTC); |
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.
throw new ContractContextException(Constants.INVALID_PUT_MUTABLE_FUNCTION_ARGUMENT_FORMAT); | ||
} | ||
|
||
throw new ContractContextException(Constants.INVALID_PUT_MUTABLE_FUNCTION_ARGUMENT_FORMAT); |
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.
This throw
statement is unreachable. The getTimeRelatedColumn
method is only called from getColumn
with a dataType
that is guaranteed to be one of DATE
, TIME
, TIMESTAMP
, or TIMESTAMPTZ
. Each of these cases is handled by an if
block with a return
statement, so this line can never be reached and should be removed.
.parallelStream() | ||
.forEach( | ||
entry -> | ||
invoke_ColumnsWithUnmatchedTypeGiven_ShouldThrowContractContextException( |
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.
The test method invoke_ColumnsWithUnmatchedTypeGiven_ShouldThrowContractContextException
was renamed to invoke_ColumnsWithInvalidArguments_ShouldThrowContractContextException
, which is a good clarification. However, the test that calls it was not renamed accordingly, which can be confusing. Renaming the test method would improve clarity and consistency.
invoke_ColumnsWithUnmatchedTypeGiven_ShouldThrowContractContextException( | |
invoke_ColumnsWithInvalidArguments_ShouldThrowContractContextException( |
This is an automated backport of the following:
Please merge this PR after all checks have passed.