Skip to content

Conversation

feeblefakie
Copy link
Contributor

This is an automated backport of the following:

Please merge this PR after all checks have passed.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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

  1. 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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();

Choose a reason for hiding this comment

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

medium

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);

Comment on lines +123 to +124
.toFormatter()
.withZone(ZoneOffset.UTC);

Choose a reason for hiding this comment

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

medium

Similar to the other formatters, TIMESTAMPTZ_FORMATTER should use ResolverStyle.STRICT to enforce strict parsing of timestamp values with a time zone. This ensures consistency and makes the parsing logic more robust.

          .toFormatter()
          .withResolverStyle(ResolverStyle.STRICT)
          .withZone(ZoneOffset.UTC);

throw new ContractContextException(Constants.INVALID_PUT_MUTABLE_FUNCTION_ARGUMENT_FORMAT);
}

throw new ContractContextException(Constants.INVALID_PUT_MUTABLE_FUNCTION_ARGUMENT_FORMAT);

Choose a reason for hiding this comment

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

medium

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(

Choose a reason for hiding this comment

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

medium

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.

Suggested change
invoke_ColumnsWithUnmatchedTypeGiven_ShouldThrowContractContextException(
invoke_ColumnsWithInvalidArguments_ShouldThrowContractContextException(

@jnmt jnmt merged commit 87fc33c into 3 Aug 1, 2025
8 checks passed
@jnmt jnmt deleted the 3-pull-200 branch August 1, 2025 10:12
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.

2 participants