Skip to content

Add timestamp type support #733

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

Merged
merged 2 commits into from
May 5, 2025
Merged

Add timestamp type support #733

merged 2 commits into from
May 5, 2025

Conversation

david-zlai
Copy link
Contributor

@david-zlai david-zlai commented May 5, 2025

Summary

Putting this up again - #684

Checklist

  • Added Unit Tests
  • Covered by existing CI
  • Integration tested
  • Documentation update

Summary by CodeRabbit

  • New Features

    • Added support for the Avro logical type timestamp-millis in schema and value conversions, enabling better handling of timestamp fields.
    • Enhanced BigQuery integration with a new test to verify correct timestamp conversions based on configuration settings.
  • Documentation

    • Added detailed comments explaining the mapping behavior of timestamp types and relevant configuration flags.
  • Refactor

    • Improved logging structure for serialized object size calculations for better readability.
    • Minor formatting and consistency improvements in test assertions.
  • Style

    • Removed unnecessary trailing whitespace for cleaner code.

imports

Try this

clean up

Add new test

more changes

fix
Copy link

coderabbitai bot commented May 5, 2025

Walkthrough

This set of changes introduces explicit handling and conversion for Avro's timestamp-millis logical type across several modules, ensuring correct mapping between Avro, Chronon, and Spark representations. It adds a new test verifying timestamp conversion behavior in the BigQuery connector under different Java time API settings. Additional changes include improved code comments, a minor logging refactor, and whitespace cleanup, with no functional modifications outside of timestamp handling and documentation.

Changes

File(s) Summary
api/python/ai/chronon/repo/gcp.py Removed a trailing whitespace line in the GcpRunner constructor.
api/src/main/scala/ai/chronon/api/DataType.scala Added a detailed comment explaining TimestampType mapping and Spark configuration flag behavior.
cloud_gcp/src/test/scala/ai/chronon/integrations/cloud_gcp/BigQueryCatalogTest.scala Added a test for timestamp conversion with/without Java 8 API; improved formatting in assertions and method calls.
online/src/main/scala/ai/chronon/online/serde/AvroConversions.scala Added explicit handling for Avro timestamp-millis in schema and value conversions; integrated with Chronon TimestampType.
spark/src/main/scala/ai/chronon/spark/GroupByUpload.scala Refactored logging to extract serialized size calculation into a separate variable before logging.
spark/src/main/scala/ai/chronon/spark/utils/InMemoryStream.scala Added Avro logical type conversion for timestamp-millis in the encode method.

Sequence Diagram(s)

sequenceDiagram
    participant SparkDF as Spark DataFrame
    participant AvroConv as AvroConversions
    participant Avro as Avro Schema
    participant Chronon as Chronon Schema

    SparkDF->>AvroConv: Write timestamp column
    AvroConv->>Avro: Map to LONG with timestamp-millis logical type
    Avro->>Chronon: toChrononSchema (timestamp-millis → TimestampType)
    Chronon->>AvroConv: fromChrononSchema (TimestampType → Avro LONG with timestamp-millis)
Loading

Suggested reviewers

  • tchow-zlai
  • piyush-zlai

Poem

Timestamps now dance in Avro's light,
With millis precise, they map just right.
Comments grow clear,
Tests bring good cheer,
And logging is tidied out of sight!

🕰️✨

Warning

Review ran into problems

🔥 Problems

GitHub Actions and Pipeline Checks: Resource not accessible by integration - https://docs.github.com/rest/actions/workflow-runs#list-workflow-runs-for-a-repository.

Please grant the required permissions to the CodeRabbit GitHub App under the organization or repository settings.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 10bb5d3 and a3a185e.

📒 Files selected for processing (6)
  • api/python/ai/chronon/repo/gcp.py (1 hunks)
  • api/src/main/scala/ai/chronon/api/DataType.scala (1 hunks)
  • cloud_gcp/src/test/scala/ai/chronon/integrations/cloud_gcp/BigQueryCatalogTest.scala (5 hunks)
  • online/src/main/scala/ai/chronon/online/serde/AvroConversions.scala (3 hunks)
  • spark/src/main/scala/ai/chronon/spark/GroupByUpload.scala (1 hunks)
  • spark/src/main/scala/ai/chronon/spark/utils/InMemoryStream.scala (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (31)
  • GitHub Check: service_commons_tests
  • GitHub Check: cloud_gcp_tests
  • GitHub Check: streaming_tests
  • GitHub Check: cloud_aws_tests
  • GitHub Check: streaming_tests
  • GitHub Check: cloud_aws_tests
  • GitHub Check: spark_tests
  • GitHub Check: spark_tests
  • GitHub Check: service_tests
  • GitHub Check: service_tests
  • GitHub Check: join_tests
  • GitHub Check: join_tests
  • GitHub Check: flink_tests
  • GitHub Check: flink_tests
  • GitHub Check: groupby_tests
  • GitHub Check: groupby_tests
  • GitHub Check: online_tests
  • GitHub Check: online_tests
  • GitHub Check: fetcher_tests
  • GitHub Check: fetcher_tests
  • GitHub Check: api_tests
  • GitHub Check: cloud_gcp_tests
  • GitHub Check: batch_tests
  • GitHub Check: analyzer_tests
  • GitHub Check: aggregator_tests
  • GitHub Check: api_tests
  • GitHub Check: analyzer_tests
  • GitHub Check: batch_tests
  • GitHub Check: scala_compile_fmt_fix
  • GitHub Check: aggregator_tests
  • GitHub Check: python_tests
🔇 Additional comments (8)
api/python/ai/chronon/repo/gcp.py (1)

61-61: Whitespace cleanup.

Minor whitespace fix - unnecessary blank line removed.

spark/src/main/scala/ai/chronon/spark/utils/InMemoryStream.scala (1)

51-52: Added timestamp conversion support.

Added explicit support for Avro's timestamp-millis logical type conversion, ensuring timestamp fields are properly handled during encoding.

api/src/main/scala/ai/chronon/api/DataType.scala (1)

170-175: Enhanced documentation for TimestampType.

Added clear documentation explaining how TimestampType maps to either java.sql.Timestamp or java.time.Instant based on the DATETIME_JAVA8API_ENABLED configuration flag.

spark/src/main/scala/ai/chronon/spark/GroupByUpload.scala (1)

98-105: Improved logging by extracting variable.

Refactored logging to extract serialized capacity into a separate variable before logging, improving code clarity.

cloud_gcp/src/test/scala/ai/chronon/integrations/cloud_gcp/BigQueryCatalogTest.scala (1)

119-130: Added test for timestamp conversion.

Added test to verify BigQuery connector correctly handles both java.time.Instant and java.sql.Timestamp types depending on Java 8 API configuration.

online/src/main/scala/ai/chronon/online/serde/AvroConversions.scala (3)

38-43: Added timestamp-millis logical type support.

Support for Avro's timestamp-millis logical type now converts to java.time.Instant.


68-70: Added conversion from Avro timestamp-millis to Chronon TimestampType.

Appropriate mapping of Avro's timestamp-millis logical type to Chronon's schema system.


127-127: Added conversion from Chronon TimestampType to Avro timestamp-millis.

Completes bidirectional conversion support for timestamps.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@david-zlai david-zlai requested a review from tchow-zlai May 5, 2025 17:44
@david-zlai david-zlai merged commit c16b583 into main May 5, 2025
35 checks passed
@david-zlai david-zlai deleted the davidhan/redo_timestamp branch May 5, 2025 18:17
chewy-zlai pushed a commit that referenced this pull request May 15, 2025
## Summary

Putting this up again - #684

## Checklist
- [ ] Added Unit Tests
- [ ] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Added support for the Avro logical type `timestamp-millis` in schema
and value conversions, enabling better handling of timestamp fields.
- Enhanced BigQuery integration with a new test to verify correct
timestamp conversions based on configuration settings.

- **Documentation**
- Added detailed comments explaining the mapping behavior of timestamp
types and relevant configuration flags.

- **Refactor**
- Improved logging structure for serialized object size calculations for
better readability.
  - Minor formatting and consistency improvements in test assertions.

- **Style**
  - Removed unnecessary trailing whitespace for cleaner code.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
chewy-zlai pushed a commit that referenced this pull request May 15, 2025
## Summary

Putting this up again - #684

## Checklist
- [ ] Added Unit Tests
- [ ] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Added support for the Avro logical type `timestamp-millis` in schema
and value conversions, enabling better handling of timestamp fields.
- Enhanced BigQuery integration with a new test to verify correct
timestamp conversions based on configuration settings.

- **Documentation**
- Added detailed comments explaining the mapping behavior of timestamp
types and relevant configuration flags.

- **Refactor**
- Improved logging structure for serialized object size calculations for
better readability.
  - Minor formatting and consistency improvements in test assertions.

- **Style**
  - Removed unnecessary trailing whitespace for cleaner code.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
chewy-zlai pushed a commit that referenced this pull request May 16, 2025
## Summary

Putting this up again - #684

## Cheour clientslist
- [ ] Added Unit Tests
- [ ] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Added support for the Avro logical type `timestamp-millis` in schema
and value conversions, enabling better handling of timestamp fields.
- Enhanced BigQuery integration with a new test to verify correct
timestamp conversions based on configuration settings.

- **Documentation**
- Added detailed comments explaining the mapping behavior of timestamp
types and relevant configuration flags.

- **Refactor**
- Improved logging structure for serialized object size calculations for
better readability.
  - Minor formatting and consistency improvements in test assertions.

- **Style**
  - Removed unnecessary trailing whitespace for cleaner code.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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