Skip to content

Conversation

@aokolnychyi
Copy link
Contributor

@aokolnychyi aokolnychyi commented Nov 4, 2025

What changes were proposed in this pull request?

This PR makes Spark reload DSv2 tables in views created using plans on each view access.

Why are the changes needed?

The current problem is that the view definition in the session catalog captures the analyzed plan that references Table (that is supposed to pin the version). If a connector doesn’t have an internal cache and produces a new Table object on each load, the table referenced in the view will become orphan and there will be no way to refresh it unless that Table instance auto refreshes on each scan (super dangerous).

Does this PR introduce any user-facing change?

Yes, but it restores the correct behavior without requiring hacks in connectors.

How was this patch tested?

TBD.

Was this patch authored or co-authored using generative AI tooling?

No.

@github-actions github-actions bot added the SQL label Nov 4, 2025
extends LeafNode with MultiInstanceRelation with NamedRelation {

override def name: String = {
s"${catalog.name()}.${identifier.quoted}"
Copy link
Contributor

@cloud-fan cloud-fan Nov 4, 2025

Choose a reason for hiding this comment

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

let's follow DataSourceV2RelationBase or create a base trait/util function

  override def name: String = {
    import org.apache.spark.sql.connector.catalog.CatalogV2Implicits._
    (catalog, identifier) match {
      case (Some(cat), Some(ident)) => s"${quoteIfNeeded(cat.name())}.${ident.quoted}"
      case _ => table.name()
    }
  }


object TableReference {

case class TableInfo(columns: Seq[Column])
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we just use StructType?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants