Skip to content

feat: add col to partition-spec #731

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 10 commits into from
May 7, 2025
Merged

Conversation

nikhil-zlai
Copy link
Contributor

@nikhil-zlai nikhil-zlai commented May 3, 2025

Summary

Checklist

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

Summary by CodeRabbit

  • New Features

    • Added optional fields for partition format and partition interval to query definitions, allowing greater flexibility in specifying partitioning behavior.
  • Refactor

    • Simplified partition specification usage across the platform by consolidating partition column, format, and interval into a single object.
    • Updated multiple interfaces and methods to derive partition column and related metadata from the unified partition specification, reducing explicit parameter passing.
    • Streamlined class and method signatures to improve consistency and maintainability.
    • Removed deprecated partition specs and adjusted related logic to use the updated partition specification format.
    • Enhanced SQL clause generation to internally use partition specification details, removing the need to pass partition column explicitly.
    • Adjusted data generation and query construction logic to rely on the updated partition specification model.
    • Simplified construction and usage of partition specifications in data processing and metadata components.
    • Improved handling of partition specs in Spark-related utilities and jobs for consistency.
  • Chores

    • Updated tests and internal utilities to align with the new partition specification structure.
    • Reduced test data volume in join tests to optimize test runtime and resource usage.

Copy link

coderabbitai bot commented May 3, 2025

Walkthrough

This change refactors how partition columns are handled across the codebase. The explicit passing of partition column names as parameters is removed from various methods and constructors. Instead, the partition column is now encapsulated within the PartitionSpec case class, which has been updated to include the column name as its first parameter. Calls and logic throughout the codebase are updated to use this new structure, simplifying method signatures and internalizing partition metadata handling.

Changes

Files/Areas Change Summary
api/thrift/api.thrift Removed extraneous blank lines near Query struct closing brace.
api/src/main/scala/ai/chronon/api/PartitionSpec.scala Added column as first param in PartitionSpec; removed hourly and fifteenMinutes; updated daily.
api/src/main/scala/ai/chronon/api/Extensions.scala Removed baseQuery; added partitionSpec method to derive spec from Query.
api/src/main/scala/ai/chronon/api/DataRange.scala PartitionRange methods use partition column from implicit PartitionSpec instead of explicit param.
aggregator/src/test/scala/ai/chronon/aggregator/test/DataGen.scala Removed explicit partitionColumn param; derive from partitionSpec internally in data generation methods.
cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/BigTableKVStoreImpl.scala Updated PartitionSpec instantiation to include partition column "ds".
flink/src/test/scala/ai/chronon/flink/test/FlinkTestUtils.scala Removed explicit PartitionSpec argument from GroupByServingInfoParsed constructor call.
online/src/main/scala/ai/chronon/online/GroupByServingInfoParsed.scala Removed PartitionSpec constructor param; now constructs internally with fixed "ds" column.
online/src/main/scala/ai/chronon/online/fetcher/MetadataStore.scala Removed mutable partitionSpec and setters; simplified GroupByServingInfoParsed instantiation.
online/src/test/scala/ai/chronon/online/test/DataRangeTest.scala Updated implicit PartitionSpec to include "ds" column in test setup.
spark/src/main/scala/ai/chronon/spark/GroupBy.scala Use partitionSpec.column and .format from local sourcePartitionSpec instead of separate vars.
spark/src/main/scala/ai/chronon/spark/GroupByUpload.scala Set dateFormat on groupByServingInfo; instantiate GroupByServingInfoParsed without PartitionSpec.
spark/src/main/scala/ai/chronon/spark/Join.scala Removed explicit "ds" argument from effectiveRange.whereClauses.
spark/src/main/scala/ai/chronon/spark/batch/MergeJob.scala Removed explicit partition column argument from effectiveRange.whereClauses.
spark/src/main/scala/ai/chronon/spark/catalog/TableUtils.scala partitionSpec now constructed with partition column; added outputPartitionSpec field with TODO comment.
spark/src/main/scala/ai/chronon/spark/stats/CompareJob.scala betweenClauses called without param; join key extraction uses column from join's PartitionSpec.
spark/src/main/scala/ai/chronon/spark/stats/PartitionRunner.scala Removed partition column argument from inputRange.whereClauses call.
spark/src/test/scala/ai/chronon/spark/test/DataFrameGen.scala Consolidated partition column into copied PartitionSpec passed to CStream.gen.
spark/src/test/scala/ai/chronon/spark/test/ResultValidationAbilityTest.scala Mocked partitionSpec now includes partition column "ds".
api/src/test/scala/ai/chronon/api/test/DateMacroSpec.scala Use PartitionSpec.daily with "ds" column in tests.
spark/src/test/scala/ai/chronon/spark/test/analyzer/DerivationTest.scala Added blank lines after .sample(0.8) calls for readability (no logic change).
spark/src/test/scala/ai/chronon/spark/test/join/JoinTest.scala Reduced test data counts by factor of 10 in multiple tests.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant PartitionSpec
  participant DataRange/Column/OtherConsumers

  Caller->>PartitionSpec: Construct with (column, format, spanMillis)
  Caller->>DataRange/Column/OtherConsumers: Call methods (no explicit partitionColumn)
  DataRange/Column/OtherConsumers->>PartitionSpec: Access .column as needed
Loading

Possibly related PRs

Suggested reviewers

  • varant-zlai
  • piyush-zlai

Poem

Partition columns, once passed by hand,
Now live in specs throughout the land.
No more clutter, no more mess—
Just cleaner code, with less to guess.
🗂️
Cheers to specs that know their place,
Bringing order, style, and grace!


📜 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 0459533 and 8be784f.

📒 Files selected for processing (6)
  • api/src/main/scala/ai/chronon/api/Extensions.scala (1 hunks)
  • api/thrift/api.thrift (1 hunks)
  • online/src/main/scala/ai/chronon/online/fetcher/MetadataStore.scala (1 hunks)
  • spark/src/main/scala/ai/chronon/spark/Join.scala (1 hunks)
  • spark/src/main/scala/ai/chronon/spark/batch/MergeJob.scala (1 hunks)
  • spark/src/main/scala/ai/chronon/spark/catalog/TableUtils.scala (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • api/thrift/api.thrift
  • online/src/main/scala/ai/chronon/online/fetcher/MetadataStore.scala
🚧 Files skipped from review as they are similar to previous changes (3)
  • spark/src/main/scala/ai/chronon/spark/Join.scala
  • spark/src/main/scala/ai/chronon/spark/batch/MergeJob.scala
  • spark/src/main/scala/ai/chronon/spark/catalog/TableUtils.scala
⏰ Context from checks skipped due to timeout of 90000ms (31)
  • GitHub Check: cloud_gcp_tests
  • GitHub Check: service_tests
  • GitHub Check: streaming_tests
  • GitHub Check: service_tests
  • GitHub Check: service_commons_tests
  • GitHub Check: streaming_tests
  • GitHub Check: spark_tests
  • GitHub Check: online_tests
  • GitHub Check: cloud_aws_tests
  • GitHub Check: join_tests
  • GitHub Check: groupby_tests
  • GitHub Check: flink_tests
  • GitHub Check: online_tests
  • GitHub Check: analyzer_tests
  • GitHub Check: groupby_tests
  • GitHub Check: cloud_gcp_tests
  • GitHub Check: flink_tests
  • GitHub Check: spark_tests
  • GitHub Check: fetcher_tests
  • GitHub Check: cloud_aws_tests
  • GitHub Check: join_tests
  • GitHub Check: api_tests
  • GitHub Check: batch_tests
  • GitHub Check: api_tests
  • GitHub Check: fetcher_tests
  • GitHub Check: aggregator_tests
  • GitHub Check: analyzer_tests
  • GitHub Check: scala_compile_fmt_fix
  • GitHub Check: aggregator_tests
  • GitHub Check: batch_tests
  • GitHub Check: enforce_triggered_workflows
🔇 Additional comments (1)
api/src/main/scala/ai/chronon/api/Extensions.scala (1)

1190-1195: Clean implementation that aligns with the partition column encapsulation goal.

The new partitionSpec method effectively extracts partition information from the query and defaults to provided values when necessary, returning a unified PartitionSpec object.


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

@@ -1133,27 +1132,11 @@ object Extensions {
result
}

// mutationsOnSnapshot table appends default values for mutation_ts and is_before column on the snapshotTable
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unused

@nikhil-zlai nikhil-zlai requested a review from tchow-zlai May 3, 2025 00:12
Copy link
Collaborator

@tchow-zlai tchow-zlai left a comment

Choose a reason for hiding this comment

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

thx for doing this! !

groupByServingInfo.setBatchEndDate(nextDay)
groupByServingInfo.setGroupBy(groupByConf)
groupByServingInfo.setKeyAvroSchema(groupBy.keySchema.toAvroSchema("Key").toString(true))
groupByServingInfo.setSelectedAvroSchema(groupBy.preAggSchema.toAvroSchema("Value").toString(true))
groupByServingInfo.setDateFormat(tableUtils.partitionFormat)
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't this come from tableUtils.partitionSpec ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

its the same thing essentially

@nikhil-zlai nikhil-zlai merged commit 23cafb1 into main May 7, 2025
34 checks passed
@nikhil-zlai nikhil-zlai deleted the nikhil/partition_spec_col branch May 7, 2025 14:00
chewy-zlai pushed a commit that referenced this pull request May 15, 2025
## Summary

## Checklist
- [ ] Added Unit Tests
- [x] 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 optional fields for partition format and partition interval to
query definitions, allowing greater flexibility in specifying
partitioning behavior.

- **Refactor**
- Simplified partition specification usage across the platform by
consolidating partition column, format, and interval into a single
object.
- Updated multiple interfaces and methods to derive partition column and
related metadata from the unified partition specification, reducing
explicit parameter passing.
- Streamlined class and method signatures to improve consistency and
maintainability.
- Removed deprecated partition specs and adjusted related logic to use
the updated partition specification format.
- Enhanced SQL clause generation to internally use partition
specification details, removing the need to pass partition column
explicitly.
- Adjusted data generation and query construction logic to rely on the
updated partition specification model.
- Simplified construction and usage of partition specifications in data
processing and metadata components.
- Improved handling of partition specs in Spark-related utilities and
jobs for consistency.

- **Chores**
- Updated tests and internal utilities to align with the new partition
specification structure.
- Reduced test data volume in join tests to optimize test runtime and
resource usage.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Thomas Chow <[email protected]>
chewy-zlai pushed a commit that referenced this pull request May 15, 2025
## Summary

## Checklist
- [ ] Added Unit Tests
- [x] 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 optional fields for partition format and partition interval to
query definitions, allowing greater flexibility in specifying
partitioning behavior.

- **Refactor**
- Simplified partition specification usage across the platform by
consolidating partition column, format, and interval into a single
object.
- Updated multiple interfaces and methods to derive partition column and
related metadata from the unified partition specification, reducing
explicit parameter passing.
- Streamlined class and method signatures to improve consistency and
maintainability.
- Removed deprecated partition specs and adjusted related logic to use
the updated partition specification format.
- Enhanced SQL clause generation to internally use partition
specification details, removing the need to pass partition column
explicitly.
- Adjusted data generation and query construction logic to rely on the
updated partition specification model.
- Simplified construction and usage of partition specifications in data
processing and metadata components.
- Improved handling of partition specs in Spark-related utilities and
jobs for consistency.

- **Chores**
- Updated tests and internal utilities to align with the new partition
specification structure.
- Reduced test data volume in join tests to optimize test runtime and
resource usage.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Thomas Chow <[email protected]>
chewy-zlai pushed a commit that referenced this pull request May 16, 2025
## Summary

## Cheour clientslist
- [ ] Added Unit Tests
- [x] 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 optional fields for partition format and partition interval to
query definitions, allowing greater flexibility in specifying
partitioning behavior.

- **Refactor**
- Simplified partition specification usage across the platform by
consolidating partition column, format, and interval into a single
object.
- Updated multiple interfaces and methods to derive partition column and
related metadata from the unified partition specification, reducing
explicit parameter passing.
- Streamlined class and method signatures to improve consistency and
maintainability.
- Removed deprecated partition specs and adjusted related logic to use
the updated partition specification format.
- Enhanced SQL clause generation to internally use partition
specification details, removing the need to pass partition column
explicitly.
- Adjusted data generation and query construction logic to rely on the
updated partition specification model.
- Simplified construction and usage of partition specifications in data
processing and metadata components.
- Improved handling of partition specs in Spark-related utilities and
jobs for consistency.

- **Chores**
- Updated tests and internal utilities to align with the new partition
specification structure.
- Reduced test data volume in join tests to optimize test runtime and
resource usage.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Thomas Chow <[email protected]>
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