Skip to content

Conversation

@varant-zlai
Copy link
Collaborator

@varant-zlai varant-zlai commented May 2, 2025

Summary

Previously, snapshot accuracy would shift the joinPart output to align with the offset. This makes it align to the original left ds.

Checklist

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

Summary by CodeRabbit

  • New Features

    • Added the ability to shift date-based partitions on DataFrames by a specified number of days.
  • Bug Fixes

    • Adjusted logic for time partition alignment during joins to prevent unnecessary date shifting.
  • Refactor

    • Applied partition shifting to specific DataFrames in batch join operations for improved processing.
    • Removed an assertion related to backfill start dates to streamline backfill logic.
    • Simplified join filtering logic by removing conditional date adjustments.
    • Removed redundant date incrementing in join and merge operations for cleaner partition handling.
  • Documentation

    • Added a clarifying comment about table name construction for improved code transparency.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 2, 2025

Walkthrough

The changes introduce a new shiftPartition method for DataFrames, enabling date-based partition shifting. This method is applied in specific cases within the join part job to shift partitions by one day. The logic for handling time partition columns in merge jobs is updated to remove the date increment step. An assertion checking for non-null backfill start date is removed from the group by logic. Additionally, a clarifying comment is added in the planner regarding table name construction. No changes were made to public entity signatures except for the new method addition.

Changes

File(s) Change Summary
api/.../RelevantLeftForJoinPart.scala Added a clarifying comment about the inclusion of leftTable in the table name.
spark/.../Extensions.scala Added shiftPartition method to DataframeOps for shifting partition columns.
spark/.../GroupBy.scala Removed assertion checking for non-null backfillStartDate.
spark/.../batch/JoinPartJob.scala Applied .shiftPartition(1) to DataFrames in specific join part cases; added min/max ds logging.
spark/.../batch/MergeJob.scala Removed date increment and formatting for time partition column in join logic; added DataFrame show calls.
spark/.../Join.scala Removed partition range adjustment logic for join filtering.
spark/.../JoinBase.scala Removed date increment logic for partition column; added min/max ts_ds logging and show after join.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DataFrame
    participant DataframeOps

    User->>DataFrame: call shiftPartition(numDays)
    activate DataFrame
    DataFrame->>DataframeOps: shiftPartition(numDays, partitionColumn)
    DataframeOps->>DataFrame: returns DataFrame with shifted partition column
    deactivate DataFrame
Loading
sequenceDiagram
    participant JoinPartJob
    participant GroupBy
    participant DataFrame

    JoinPartJob->>GroupBy: snapshotEvents/snapshotEntities
    GroupBy-->>JoinPartJob: DataFrame
    JoinPartJob->>DataFrame: shiftPartition(1)
    DataFrame-->>JoinPartJob: shifted DataFrame
Loading

Possibly related PRs

Suggested reviewers

  • nikhil-zlai
  • piyush-zlai

Poem

Shift the date, the code aligns,
Partitions move along the lines.
Assertions gone, the checks are light,
Comments clarify the naming right.
With every join and merge anew,
The codebase shines with something true!
🚀

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.


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

@varant-zlai varant-zlai force-pushed the vz--align_output_date_for_snapshot_joinparts branch from 2621fbf to 97aec92 Compare May 2, 2025 04:45
@varant-zlai varant-zlai force-pushed the vz--align_output_date_for_snapshot_joinparts branch from d69041f to ed9dc23 Compare May 2, 2025 20:55
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
spark/src/main/scala/ai/chronon/spark/JoinBase.scala (2)

110-114: Added debugging output.

Shows min/max of ts_ds before join for troubleshooting.

Consider removing or conditionalizing this debug output before production deployment:

-    leftDf.selectExpr("min(ts_ds) as min_ds", "max(ts_ds) as max_ds").show()
-    joinableRightDf.selectExpr("min(ts_ds) as min_ds", "max(ts_ds) as max_ds").show()
-    //renamedLeftDf.selectExpr("min(ds) as min_ds", "max(ds) as max_ds").show()
-    //    rightDf.selectExpr("min(ds) as min_ds", "max(ds) as max_ds").show()
+    if (logger.isDebugEnabled()) {
+      leftDf.selectExpr("min(ts_ds) as min_ds", "max(ts_ds) as max_ds").show()
+      joinableRightDf.selectExpr("min(ts_ds) as min_ds", "max(ts_ds) as max_ds").show()
+    }

126-126: Added join result debugging.

Shows the joined DataFrame for troubleshooting.

Similar to the earlier debug output, consider conditionalizing:

-    joinedDf.show()
+    if (logger.isDebugEnabled()) {
+      joinedDf.show()
+    }
📜 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 d69041f and ed9dc23.

📒 Files selected for processing (4)
  • spark/src/main/scala/ai/chronon/spark/Join.scala (1 hunks)
  • spark/src/main/scala/ai/chronon/spark/JoinBase.scala (2 hunks)
  • spark/src/main/scala/ai/chronon/spark/batch/JoinPartJob.scala (3 hunks)
  • spark/src/main/scala/ai/chronon/spark/batch/MergeJob.scala (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • spark/src/main/scala/ai/chronon/spark/batch/MergeJob.scala
  • spark/src/main/scala/ai/chronon/spark/batch/JoinPartJob.scala
🧰 Additional context used
🧬 Code Graph Analysis (1)
spark/src/main/scala/ai/chronon/spark/Join.scala (2)
spark/src/main/scala/ai/chronon/spark/catalog/TableUtils.scala (1)
  • whereClauses (587-591)
api/src/main/scala/ai/chronon/api/DataRange.scala (1)
  • whereClauses (78-80)
⏰ Context from checks skipped due to timeout of 90000ms (31)
  • GitHub Check: streaming_tests
  • GitHub Check: service_commons_tests
  • GitHub Check: service_tests
  • GitHub Check: analyzer_tests
  • GitHub Check: join_tests
  • GitHub Check: cloud_gcp_tests
  • GitHub Check: online_tests
  • GitHub Check: streaming_tests
  • GitHub Check: groupby_tests
  • GitHub Check: cloud_aws_tests
  • GitHub Check: flink_tests
  • GitHub Check: spark_tests
  • GitHub Check: service_tests
  • GitHub Check: fetcher_tests
  • GitHub Check: cloud_gcp_tests
  • GitHub Check: batch_tests
  • GitHub Check: online_tests
  • GitHub Check: analyzer_tests
  • GitHub Check: cloud_aws_tests
  • GitHub Check: groupby_tests
  • GitHub Check: flink_tests
  • GitHub Check: spark_tests
  • GitHub Check: api_tests
  • GitHub Check: join_tests
  • GitHub Check: scala_compile_fmt_fix
  • GitHub Check: api_tests
  • GitHub Check: batch_tests
  • GitHub Check: aggregator_tests
  • GitHub Check: fetcher_tests
  • GitHub Check: aggregator_tests
  • GitHub Check: enforce_triggered_workflows
🔇 Additional comments (2)
spark/src/main/scala/ai/chronon/spark/Join.scala (1)

201-201: Simplified partition filtering logic.

Now directly using original leftRange for where clauses instead of conditional adjustment.

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

103-103: Removed date increment logic.

Now directly using the partition column without transformation, aligning with PR objective.

@varant-zlai varant-zlai closed this May 2, 2025
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.

3 participants