-
Notifications
You must be signed in to change notification settings - Fork 9
feat: Use project id that's specified in the table name for the bigquery connector #500
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
Conversation
WalkthroughThis PR refactors and streamlines the BigQuery integration and related Spark components. The Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant GcpFormatProvider
participant BigQueryUtil
participant BigQueryClient
participant Definition
Caller->>GcpFormatProvider: readFormat(tableName)
GcpFormatProvider->>BigQueryUtil: parseTableId(tableName)
BigQueryUtil-->>GcpFormatProvider: TableId(project, dataset, table)
GcpFormatProvider->>BigQueryClient: getTable(TableId)
BigQueryClient-->>GcpFormatProvider: Table definition
GcpFormatProvider->>Definition: getFormat(definition)
Definition-->>GcpFormatProvider: Format info
GcpFormatProvider-->>Caller: Format Option
Possibly related PRs
Suggested reviewers
Poem
Warning Review ran into problems🔥 ProblemsGitHub 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Co-authored-by: Thomas Chow <[email protected]> Co-authored-by: Thomas Chow <[email protected]>
Co-authored-by: Thomas Chow <[email protected]> Co-authored-by: Thomas Chow <[email protected]>
Co-authored-by: Thomas Chow <[email protected]> Co-authored-by: Thomas Chow <[email protected]>
cfceeff to
a0d29ef
Compare
david-zlai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple of questions but makes sense
| val multipartIdentifier = | ||
| sparkSession.sessionState.sqlParser.parseMultipartIdentifier(tableName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would be to make things consistent with spark. For example, using backticks in spark:
`etsy-zipline-dev`.search.table_namewould be handled differently in the bigquery parser and the spark sql parser. Ideally we just want to use spark syntax and pass the results to bigquery.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me write a test for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
| import ai.chronon.api.Query | ||
| import ai.chronon.api.QueryUtils | ||
| import ai.chronon.api.TsUtils | ||
| import ai.chronon.api.{Constants, PartitionRange, PartitionSpec, Query, QueryUtils, TsUtils} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which convention should we be using haha
feel like mine has been breaking them out individually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like it makes more sense to bracket them but no strong opinions.
david-zlai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tchow-zlai - let's run an integration test if we can beforehand though
Co-authored-by: Thomas Chow <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/BigQueryFormat.scala (1)
64-95: Consider refactoring partition format handlingThe TODO comment about partition format indicates this is a temporary solution.
Should we address this now or track it as a separate issue?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (4)
cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/BigQueryFormat.scala(4 hunks)cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/GcpFormatProvider.scala(4 hunks)cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/SparkBQUtils.scala(1 hunks)cloud_gcp/src/test/scala/ai/chronon/integrations/cloud_gcp/BigQueryCatalogTest.scala(4 hunks)
🧰 Additional context used
🧠 Learnings (3)
cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/SparkBQUtils.scala (1)
Learnt from: tchow-zlai
PR: zipline-ai/chronon#263
File: cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/BigQueryFormat.scala:29-60
Timestamp: 2025-03-12T15:28:06.350Z
Learning: In BigQuery integration, table existence check is performed outside the BigQueryFormat.createTable method, at a higher level in TableUtils.createTable.
cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/BigQueryFormat.scala (2)
Learnt from: tchow-zlai
PR: zipline-ai/chronon#263
File: cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/BigQueryFormat.scala:29-60
Timestamp: 2025-03-12T15:28:06.350Z
Learning: In BigQuery integration, table existence check is performed outside the BigQueryFormat.createTable method, at a higher level in TableUtils.createTable.
Learnt from: tchow-zlai
PR: zipline-ai/chronon#263
File: cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/BigQueryFormat.scala:56-57
Timestamp: 2025-03-12T15:28:06.350Z
Learning: For BigQuery table creation operations in BigQueryFormat.scala, allow exceptions to propagate directly without wrapping them in try-catch blocks, as the original BigQuery exceptions provide sufficient context.
cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/GcpFormatProvider.scala (2)
Learnt from: tchow-zlai
PR: zipline-ai/chronon#263
File: cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/BigQueryFormat.scala:29-60
Timestamp: 2025-03-12T15:28:06.350Z
Learning: In BigQuery integration, table existence check is performed outside the BigQueryFormat.createTable method, at a higher level in TableUtils.createTable.
Learnt from: tchow-zlai
PR: zipline-ai/chronon#263
File: cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/BigQueryFormat.scala:56-57
Timestamp: 2025-03-12T15:28:06.350Z
Learning: For BigQuery table creation operations in BigQueryFormat.scala, allow exceptions to propagate directly without wrapping them in try-catch blocks, as the original BigQuery exceptions provide sufficient context.
⏰ Context from checks skipped due to timeout of 90000ms (15)
- GitHub Check: streaming_tests
- GitHub Check: join_tests
- GitHub Check: streaming_tests
- GitHub Check: groupby_tests
- GitHub Check: groupby_tests
- GitHub Check: analyzer_tests
- GitHub Check: fetcher_tests
- GitHub Check: fetcher_tests
- GitHub Check: analyzer_tests
- GitHub Check: spark_tests
- GitHub Check: join_tests
- GitHub Check: spark_tests
- GitHub Check: scala_compile_fmt_fix
- GitHub Check: non_spark_tests
- GitHub Check: non_spark_tests
🔇 Additional comments (9)
cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/SparkBQUtils.scala (1)
8-15: LGTM - Clean utility implementationThis utility method correctly handles table name parsing for BigQuery, addressing project ID requirements.
cloud_gcp/src/test/scala/ai/chronon/integrations/cloud_gcp/BigQueryCatalogTest.scala (2)
69-82: LGTM - Thorough table name parsing testTest verifies proper handling of project IDs with backticks for Spark compatibility.
107-107: LGTM - Updated external table referenceExternal table reference now includes catalog prefix.
cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/GcpFormatProvider.scala (3)
25-28: LGTM - Simplified table lookup using SparkBQUtilsRefactored code now directly parses table names using the new utility method.
45-52: LGTM - Simplified property accessDirect property access from definition improves code readability.
58-58: LGTM - Removed unnecessary parametersBigQueryFormat is now a case object with no parameters.
cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/BigQueryFormat.scala (3)
10-11: LGTM - Converted to case objectChanged from case class to case object and removed constructor parameters.
28-33: LGTM - Uses table identifier to determine projectCorrectly retrieves project from table identifier or falls back to default.
38-38: LGTM - Updated project reference in queriesSQL queries now use providedProject from TableId.
Also applies to: 59-59, 71-71
cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/SparkBQUtils.scala
Show resolved
Hide resolved
| "spark.sql.catalogImplementation" -> "in-memory", | ||
|
|
||
| // "spark.sql.defaultCatalog" -> "default_iceberg", | ||
| // "spark.sql.catalog.default_iceberg" -> classOf[SparkCatalog].getName, | ||
| // "spark.sql.catalog.default_iceberg.catalog-impl" -> classOf[BQMSCatalog].getName, | ||
| // "spark.sql.catalog.default_iceberg.io-impl" -> classOf[ResolvingFileIO].getName, | ||
| // "spark.sql.catalog.default_iceberg.warehouse" -> "gs://zipline-warehouse-canary/data/tables/", | ||
| // "spark.sql.catalog.default_iceberg.gcp_location" -> "us-central1", | ||
| // "spark.sql.catalog.default_iceberg.gcp_project" -> "canary-443022", | ||
| // | ||
| // | ||
| // "spark.sql.catalogImplementation" -> "in-memory", | ||
| // "spark.kryo.registrator" -> classOf[ChrononIcebergKryoRegistrator].getName, | ||
| // "spark.sql.defaultUrlStreamHandlerFactory.enabled" -> false.toString, | ||
| // | ||
| // "spark.sql.catalog.default_bigquery" -> classOf[BigQueryCatalog].getName, | ||
| )) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Consider uncommenting catalog configurations
The Spark SQL catalog configurations are now commented out. Verify if they should remain this way.
🏁 Script executed:
#!/bin/bash
# Verify if catalog configurations are used elsewhere
rg "spark.sql.catalog" --type scala -A 2 -B 2Length of output: 6581
Action: Clarify Catalog Config in BigQuery Test
The test intentionally uses "spark.sql.catalogImplementation" -> "in-memory". The legacy, commented-out catalog configurations (for default_iceberg/default_bigquery) aren’t active anywhere. Please either remove these lines to reduce noise or add comments explaining their intended future use.
Done - had to update the |
…ery connector (#500) ## Summary - This PR cleans up a few abstractions in the GCPFormatProvider - Clean up some projectId handling - In the unit tests, sent a commented example configuration set for multiple catalogs. ## 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 - **Refactor** - Streamlined BigQuery integration with improved table identifier parsing and project recognition. - Enhanced error messaging, now providing clearer feedback when database information is missing. - Simplified the process for detecting table formats for more consistent data access. - Consolidated import statements for better organization. - **New Features** - Introduced a new utility for converting table names into a structured format. - **Tests** - Added a new test case to verify table name parsing consistency. - Updated Spark SQL catalog configuration to ensure reliable referencing of external tables. <!-- 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"} ``` --> --------- Co-authored-by: Thomas Chow <[email protected]>
…ery connector (#500) ## Summary - This PR cleans up a few abstractions in the GCPFormatProvider - Clean up some projectId handling - In the unit tests, sent a commented example configuration set for multiple catalogs. ## 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 - **Refactor** - Streamlined BigQuery integration with improved table identifier parsing and project recognition. - Enhanced error messaging, now providing clearer feedback when database information is missing. - Simplified the process for detecting table formats for more consistent data access. - Consolidated import statements for better organization. - **New Features** - Introduced a new utility for converting table names into a structured format. - **Tests** - Added a new test case to verify table name parsing consistency. - Updated Spark SQL catalog configuration to ensure reliable referencing of external tables. <!-- 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"} ``` --> --------- Co-authored-by: Thomas Chow <[email protected]>
…ery connector (#500) ## Summary - This PR cleans up a few abstractions in the GCPFormatProvider - Clean up some projectId handling - In the unit tests, sent a commented example configuration set for multiple catalogs. ## 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 - **Refactor** - Streamlined BigQuery integration with improved table identifier parsing and project recognition. - Enhanced error messaging, now providing clearer feedback when database information is missing. - Simplified the process for detecting table formats for more consistent data access. - Consolidated import statements for better organization. - **New Features** - Introduced a new utility for converting table names into a structured format. - **Tests** - Added a new test case to verify table name parsing consistency. - Updated Spark SQL catalog configuration to ensure reliable referencing of external tables. <!-- 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"} ``` --> --------- Co-authored-by: Thomas Chow <[email protected]>
…ery connector (#500) ## Summary - This PR cleans up a few abstractions in the GCPFormatProvider - Clean up some projectId handling - In the unit tests, sent a commented example configuration set for multiple catalogs. ## 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 - **Refactor** - Streamlined BigQuery integration with improved table identifier parsing and project recognition. - Enhanced error messaging, now providing clearer feedback when database information is missing. - Simplified the process for detecting table formats for more consistent data access. - Consolidated import statements for better organization. - **New Features** - Introduced a new utility for converting table names into a structured format. - **Tests** - Added a new test case to verify table name parsing consistency. - Updated Spark SQL catalog configuration to ensure reliable referencing of external tables. <!-- 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"} ``` --> --------- Co-authored-by: Thomas Chow <[email protected]>
…ery connector (#500) ## Summary - This PR cleans up a few abstractions in the GCPFormatProvider - Clean up some projectId handling - In the unit tests, sent a commented example configuration set for multiple catalogs. ## 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 - **Refactor** - Streamlined BigQuery integration with improved table identifier parsing and project recognition. - Enhanced error messaging, now providing clearer feedbaour clients when database information is missing. - Simplified the process for detecting table formats for more consistent data access. - Consolidated import statements for better organization. - **New Features** - Introduced a new utility for converting table names into a structured format. - **Tests** - Added a new test case to verify table name parsing consistency. - Updated Spark SQL catalog configuration to ensure reliable referencing of external tables. <!-- 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"} ``` --> --------- Co-authored-by: Thomas Chow <[email protected]>
Summary
Checklist
Summary by CodeRabbit
Refactor
New Features
Tests