Skip to content

Revert "chore: Remove use of DelegatingTable and bubble up exceptions properly" #661

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

Closed
wants to merge 1 commit into from

Conversation

david-zlai
Copy link
Contributor

@david-zlai david-zlai commented Apr 17, 2025

Reverts #638

Summary by CodeRabbit

  • New Features

    • Enhanced table loading to enrich metadata with explicit properties such as provider type and external status for unified handling of tables from different sources.
  • Bug Fixes

    • Fixed error messaging for unsupported table types to display the correct table name.
  • Refactor

    • Streamlined table loading logic for improved property management and error handling.
    • Simplified format detection by using table properties instead of runtime type checks.

Copy link

coderabbitai bot commented Apr 17, 2025

Walkthrough

This change introduces a DelegatingTable class that wraps Spark Table instances, allowing additional properties and optional custom partitioning to be merged or overridden. The DelegatingBigQueryMetastoreCatalog's loadTable method is refactored to always return tables wrapped in DelegatingTable, enriching them with explicit properties such as provider type and external status, and unifying error handling. In GcpFormatProvider, the logic for determining table format now relies on the provider property from the table's properties map, rather than on table class types.

Changes

File(s) Change Summary
.../DelegatingBigQueryMetastoreCatalog.scala Introduced DelegatingTable class; refactored loadTable to wrap tables with DelegatingTable, unify property annotations, and streamline error handling.
.../GcpFormatProvider.scala Changed readFormat to determine format based on table's provider property instead of class type; removed unused imports.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant Catalog as DelegatingBigQueryMetastoreCatalog
    participant Iceberg
    participant BQ as BigQuery
    participant DT as DelegatingTable

    Caller->>Catalog: loadTable(ident)
    Catalog->>Iceberg: try loadTable(ident)
    alt Iceberg table found
        Iceberg-->>Catalog: Table
        Catalog->>DT: wrap Table with provider=ICEBERG, external=false
        DT-->>Catalog: DelegatingTable
    else Iceberg table not found
        Catalog->>BQ: getTable(ident)
        alt ExternalTable
            BQ-->>Catalog: ExternalTableDefinition
            Catalog->>DT: wrap ParquetTable with provider=PARQUET, external=true, location
            DT-->>Catalog: DelegatingTable
        else StandardTable
            BQ-->>Catalog: StandardTableDefinition
            Catalog->>DT: wrap Table with provider=BIGQUERY, external=false
            DT-->>Catalog: DelegatingTable
        end
    end
    Catalog-->>Caller: DelegatingTable
Loading

Possibly related PRs

Suggested reviewers

  • piyush-zlai
  • nikhil-zlai

Poem

Tables now wear a clever disguise,
Wrapped in a shell both neat and wise.
Properties merged, providers clear,
Iceberg or BigQuery—no more fear!
Catalogs unified, logic refined,
Sparkling new wrappers for data aligned.
🎩✨

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.

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

Copy link

@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: 3

🧹 Nitpick comments (2)
cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/DelegatingBigQueryMetastoreCatalog.scala (1)

56-58: Clarify property precedence.

internalTable.properties ++ additionalProperties lets extras override clashes (good).
A comment here would save readers an extra mental hop.

cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/GcpFormatProvider.scala (1)

29-41: Swallowing errors hides root cause.

Try(...).toOption returns None on any error, losing details.
Consider recoverWith that logs or re‑raises unsupported provider issues.

📜 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 0a4115a and 53b06da.

📒 Files selected for processing (2)
  • cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/DelegatingBigQueryMetastoreCatalog.scala (4 hunks)
  • cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/GcpFormatProvider.scala (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (18)
  • GitHub Check: service_tests
  • GitHub Check: hub_tests
  • GitHub Check: service_tests
  • GitHub Check: service_commons_tests
  • GitHub Check: hub_tests
  • GitHub Check: online_tests
  • GitHub Check: cloud_aws_tests
  • GitHub Check: cloud_gcp_tests
  • GitHub Check: flink_tests
  • GitHub Check: cloud_aws_tests
  • GitHub Check: online_tests
  • GitHub Check: flink_tests
  • GitHub Check: api_tests
  • GitHub Check: api_tests
  • GitHub Check: cloud_gcp_tests
  • GitHub Check: scala_compile_fmt_fix
  • GitHub Check: aggregator_tests
  • GitHub Check: aggregator_tests

Comment on lines +50 to +55
override def newScanBuilder(options: CaseInsensitiveStringMap): ScanBuilder =
internalTable.asInstanceOf[SupportsRead].newScanBuilder(options)

override def newWriteBuilder(info: LogicalWriteInfo): WriteBuilder =
internalTable.asInstanceOf[SupportsWrite].newWriteBuilder(info)

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Guard the casts to SupportsRead/Write.

asInstanceOf will blow up if internalTable lacks SupportsRead/SupportsWrite.
Prefer pattern‑match or collect { case t: SupportsRead => … } to fail fast with a clearer message.

Comment on lines 120 to 126
Try {
icebergCatalog.loadTable(identNoCatalog)
val icebergSparkTable = icebergCatalog.loadTable(identNoCatalog)
DelegatingTable(icebergSparkTable,
additionalProperties =
Map(TableCatalog.PROP_EXTERNAL -> "false", TableCatalog.PROP_PROVIDER -> "ICEBERG"))
}
.recover {
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Too broad fallback.

recover { case _ => … } hides non‑existence and real errors alike.
Match _: NoSuchTableException explicitly to avoid masking genuine failures.

Comment on lines +137 to 138
val table = bigQueryClient.getTable(tId)
table.getDefinition.asInstanceOf[TableDefinition] match {
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Null‑safe BigQuery lookup needed.

getTable returns null when absent → NPE later.
Wrap with Option(...) and throw NoSuchTableException early.

-          val table = bigQueryClient.getTable(tId)
+          val table = Option(bigQueryClient.getTable(tId))
+            .getOrElse(throw new NoSuchTableException(s"Table $tId not found in BigQuery"))

@david-zlai david-zlai closed this Apr 17, 2025
@david-zlai david-zlai deleted the revert-638-tchow/bq-native-through-catalog branch May 12, 2025 19:36
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.

1 participant