Skip to content

Conversation

@tchow-zlai
Copy link
Collaborator

@tchow-zlai tchow-zlai commented Dec 13, 2024

Summary

Checklist

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

Summary by CodeRabbit

  • New Features

    • Introduced an online execution context for specific join operations.
    • Added a new test case for dynamic partitioning in Spark.
  • Bug Fixes

    • Adjusted Spark session configuration for partition overwrite mode to ensure future compatibility.
  • Chores

    • Removed unnecessary JAR file dependency from Spark job submission, simplifying the process.
    • Updated JAR URI configuration to a new storage location.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 13, 2024

Walkthrough

The changes in this pull request involve modifications to four main files: training_set.py, DataprocSubmitter.scala, SparkSessionBuilder.scala, and dataproc-submitter-conf.yaml. The training_set.py file sees adjustments in the configuration of join instances, particularly with the introduction of an online execution context for one of the joins. The DataprocSubmitter.scala file removes a commented-out JAR file URI for BigQuery from the job submission process, simplifying the configuration. The SparkSessionBuilder.scala file updates a Spark configuration setting to ensure compatibility with future updates. Additionally, the dataproc-submitter-conf.yaml file changes the JAR URI to a new storage location.

Changes

File Path Change Summary
api/py/test/sample/joins/quickstart/training_set.py Adjusted formatting of table parameter in EventSource; modified v2 Join to include online=True and limited GroupBy entities to purchases_v1 and returns_v1.
cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/DataprocSubmitter.scala Removed commented-out JAR file URI for BigQuery from the submit method, simplifying job submission configuration.
spark/src/main/scala/ai/chronon/spark/SparkSessionBuilder.scala Updated spark.sql.sources.partitionOverwriteMode from "dynamic" to "DYNAMIC" for compatibility with future updates.
cloud_gcp/src/main/resources/dataproc-submitter-conf.yaml Changed jarUri configuration from a temporary bucket to a new storage location under gs://zipline-jars/.
spark/src/test/scala/ai/chronon/spark/test/JoinTest.scala Added TestRow case class and an implicit Ordering for it; introduced a new test case for dynamic partition overwrite functionality.

Poem

In the fields where data plays,
Joins and submits in wondrous ways.
With Spark we dance, configurations bright,
Online we gather, in the soft moonlight.
Hops of code, a joyful spree,
Changes made, oh, let it be! 🐇✨


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

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 docstrings to generate docstrings for this PR. (Beta)
  • @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.

@tchow-zlai tchow-zlai force-pushed the tchow/dataproc-quickstart branch 2 times, most recently from 4b58ac3 to 5760be9 Compare December 13, 2024 05:58
@tchow-zlai tchow-zlai changed the title wip feat: support dataproc federated bigquery catalog Dec 13, 2024
@tchow-zlai tchow-zlai force-pushed the tchow/spark-submission branch from 68ae7f0 to 766f7e5 Compare December 13, 2024 18:34
Copy link
Collaborator

@chewy-zlai chewy-zlai left a comment

Choose a reason for hiding this comment

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

A couple of small nits

@tchow-zlai tchow-zlai force-pushed the tchow/dataproc-quickstart branch from f74a8bd to 450524b Compare December 13, 2024 21:36
Base automatically changed from tchow/spark-submission to main December 13, 2024 22:34
@tchow-zlai tchow-zlai force-pushed the tchow/dataproc-quickstart branch from 450524b to ad8617b Compare December 13, 2024 22:38
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 (1)
spark/src/test/scala/ai/chronon/spark/test/JoinTest.scala (1)

72-109: Enhance test robustness and cleanup.

While the test case correctly verifies the dynamic partition overwrite functionality, consider the following improvements:

  1. Add cleanup of test data to prevent test pollution
  2. Replace generic assertions with more descriptive ones
  3. Remove or guard debug show() statements with a flag

Consider applying these changes:

  test("testing basic spark dynamic partition overwrite") {
    import org.apache.spark.sql.SaveMode
    import spark.implicits._

+   // Clean up test table if exists
+   spark.sql(f"DROP TABLE IF EXISTS ${namespace}.table")

    val rows = List(
      TestRow("1", "a"),
      TestRow("2", "b"),
      TestRow("3", "c"),
      TestRow("4", "d"),
      TestRow("5", "e")
    )
    val data = spark.createDataFrame(rows) toDF ("ds", "value")
    data.write.mode(SaveMode.Overwrite).format("hive").partitionBy("ds").saveAsTable(f"${namespace}.table")
-   assertEquals(spark.table(f"${namespace}.table").as[TestRow].collect().toList.sorted, rows.sorted)
+   assertResult(rows.sorted, "Initial data write failed")(
+     spark.table(f"${namespace}.table").as[TestRow].collect().toList.sorted
+   )

-   spark.table(f"${namespace}.table").show(truncate = false)
+   if (debugEnabled) {
+     spark.table(f"${namespace}.table").show(truncate = false)
+   }

    val dynamicPartitions = List(
      TestRow("4", "y"),
      TestRow("5", "z")
    )
    val dynamicPartitionsDF = spark.createDataset(dynamicPartitions).select("value", "ds")

    dynamicPartitionsDF.write
      .format("hive")
      .mode(SaveMode.Overwrite)
      .insertInto(f"${namespace}.table")

-   spark.table(f"${namespace}.table").show(truncate = false)
+   if (debugEnabled) {
+     spark.table(f"${namespace}.table").show(truncate = false)
+   }

    val updatedExpected =
      (rows.map((r) => r.ds -> r.value).toMap ++ dynamicPartitions.map((r) => r.ds -> r.value).toMap).map {
        case (k, v) => TestRow(k, v)
      }.toList

-   assertEquals(updatedExpected.sorted, spark.table(f"${namespace}.table").as[TestRow].collect().toList.sorted)
+   assertResult(updatedExpected.sorted, "Dynamic partition overwrite failed")(
+     spark.table(f"${namespace}.table").as[TestRow].collect().toList.sorted
+   )

+   // Clean up test data
+   spark.sql(f"DROP TABLE IF EXISTS ${namespace}.table")
  }
📜 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 8ac2096 and 6361df1.

📒 Files selected for processing (1)
  • spark/src/test/scala/ai/chronon/spark/test/JoinTest.scala (2 hunks)
🔇 Additional comments (1)
spark/src/test/scala/ai/chronon/spark/test/JoinTest.scala (1)

46-55: LGTM! Well-structured case class and companion object.

The implementation is clean and follows Scala best practices. The implicit ordering is correctly implemented for sorting TestRow instances based on the ds field.

@tchow-zlai
Copy link
Collaborator Author

ptal @chewy-zlai | @piyush-zlai

@tchow-zlai tchow-zlai merged commit e127fb7 into main Dec 17, 2024
9 checks passed
@tchow-zlai tchow-zlai deleted the tchow/dataproc-quickstart branch December 17, 2024 21:12
This was referenced Dec 21, 2024
@coderabbitai coderabbitai bot mentioned this pull request Mar 4, 2025
4 tasks
kumar-zlai pushed a commit that referenced this pull request Apr 25, 2025
## Summary
- https://app.asana.com/0/1208949807589885/1208951092959581
- this PR is the followup to enabling the `spark-bigquery-connector`. It
introduces the minimal fallback where a dataproc cluster is configured
with a federated endpoint, as described in
https://docs.google.com/document/d/1bxNUeaVrWDRL07fyLWiBDwO6pLS9BUbPbMLSnbRDRCk/edit?tab=t.0#heading=h.917ddfitv46i
. From this perspective, a bigquery catalog looks like a hive metastore.
We can access it through typical catalog api's, and dataproc will proxy
at the API service layer. Minimal code change!
- We do need a slight change to workaround a bug in the latest version
of the connector though.

## 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**
	- Introduced an online execution context for specific join operations.
	- Added a new test case for dynamic partitioning in Spark.

- **Bug Fixes**
- Adjusted Spark session configuration for partition overwrite mode to
ensure future compatibility.

- **Chores**
- Removed unnecessary JAR file dependency from Spark job submission,
simplifying the process.
	- Updated JAR URI configuration to a new storage location.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

<!-- av pr metadata
This information is embedded by the av CLI when creating PRs to track
the status of stacks when using Aviator. Please do not delete or edit
this section of the PR.
```
{"parent":"main","parentHead":"","trunk":"main"}
```
-->
kumar-zlai pushed a commit that referenced this pull request Apr 29, 2025
## Summary
- https://app.asana.com/0/1208949807589885/1208951092959581
- this PR is the followup to enabling the `spark-bigquery-connector`. It
introduces the minimal fallback where a dataproc cluster is configured
with a federated endpoint, as described in
https://docs.google.com/document/d/1bxNUeaVrWDRL07fyLWiBDwO6pLS9BUbPbMLSnbRDRCk/edit?tab=t.0#heading=h.917ddfitv46i
. From this perspective, a bigquery catalog looks like a hive metastore.
We can access it through typical catalog api's, and dataproc will proxy
at the API service layer. Minimal code change!
- We do need a slight change to workaround a bug in the latest version
of the connector though.

## 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**
	- Introduced an online execution context for specific join operations.
	- Added a new test case for dynamic partitioning in Spark.

- **Bug Fixes**
- Adjusted Spark session configuration for partition overwrite mode to
ensure future compatibility.

- **Chores**
- Removed unnecessary JAR file dependency from Spark job submission,
simplifying the process.
	- Updated JAR URI configuration to a new storage location.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

<!-- av pr metadata
This information is embedded by the av CLI when creating PRs to track
the status of stacks when using Aviator. Please do not delete or edit
this section of the PR.
```
{"parent":"main","parentHead":"","trunk":"main"}
```
-->
chewy-zlai pushed a commit that referenced this pull request May 15, 2025
## Summary
- https://app.asana.com/0/1208949807589885/1208951092959581
- this PR is the followup to enabling the `spark-bigquery-connector`. It
introduces the minimal fallback where a dataproc cluster is configured
with a federated endpoint, as described in
https://docs.google.com/document/d/1bxNUeaVrWDRL07fyLWiBDwO6pLS9BUbPbMLSnbRDRCk/edit?tab=t.0#heading=h.917ddfitv46i
. From this perspective, a bigquery catalog looks like a hive metastore.
We can access it through typical catalog api's, and dataproc will proxy
at the API service layer. Minimal code change!
- We do need a slight change to workaround a bug in the latest version
of the connector though.

## 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**
	- Introduced an online execution context for specific join operations.
	- Added a new test case for dynamic partitioning in Spark.

- **Bug Fixes**
- Adjusted Spark session configuration for partition overwrite mode to
ensure future compatibility.

- **Chores**
- Removed unnecessary JAR file dependency from Spark job submission,
simplifying the process.
	- Updated JAR URI configuration to a new storage location.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

<!-- av pr metadata
This information is embedded by the av CLI when creating PRs to track
the status of stacks when using Aviator. Please do not delete or edit
this section of the PR.
```
{"parent":"main","parentHead":"","trunk":"main"}
```
-->
chewy-zlai pushed a commit that referenced this pull request May 16, 2025
## Summary
- https://app.asana.com/0/1208949807589885/1208951092959581
- this PR is the followup to enabling the `spark-bigquery-connector`. It
introduces the minimal fallbaour clients where a dataproc cluster is configured
with a federated endpoint, as described in
https://docs.google.com/document/d/1bxNUeaVrWDRL07fyLWiBDwO6pLS9BUbPbMLSnbRDRCk/edit?tab=t.0#heading=h.917ddfitv46i
. From this perspective, a bigquery catalog looks like a hive metastore.
We can access it through typical catalog api's, and dataproc will proxy
at the API service layer. Minimal code change!
- We do need a slight change to workaround a bug in the latest version
of the connector though.

## 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**
	- Introduced an online execution context for specific join operations.
	- Added a new test case for dynamic partitioning in Spark.

- **Bug Fixes**
- Adjusted Spark session configuration for partition overwrite mode to
ensure future compatibility.

- **Chores**
- Removed unnecessary JAR file dependency from Spark job submission,
simplifying the process.
	- Updated JAR URI configuration to a new storage location.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

<!-- av pr metadata
This information is embedded by the av CLI when creating PRs to traour clients
the status of staour clientss when using Aviator. Please do not delete or edit
this section of the PR.
```
{"parent":"main","parentHead":"","trunk":"main"}
```
-->
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.

4 participants