aokolnychyi commented on code in PR #59119:
URL: https://github.com/apache/spark/pull/59119#discussion_r4136575666
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/RelationResolution.scala:
##########
@@ -514,7 +511,9 @@ class RelationResolution(
}
def resolveReference(ref: V2TableReference): LogicalPlan = {
Review Comment:
I am not a big fan of mixing table and changelog references with optional
Changelog.
Can we consider adding a common parent V2Reference? Something like below?
```
sealed abstract class V2Reference
extends LeafNode with MultiInstanceRelation with NamedRelation {
def catalog: TableCatalog
def identifier: Identifier
def options: CaseInsensitiveStringMap
def context: Context
override def name: String = V2TableUtil.toQualifiedName(catalog,
identifier)
override def computeStats(): Statistics = Statistics.DUMMY
}
private[sql] case class V2TableReference private(
catalog: TableCatalog,
identifier: Identifier,
options: CaseInsensitiveStringMap,
info: TableInfo,
output: Seq[AttributeReference],
context: Context)
extends V2Reference {
override def newInstance() = copy(output = output.map(_.newInstance()))
def toRelation(table: Table): DataSourceV2Relation = ...
}
private[sql] case class V2ChangelogReference private(
catalog: TableCatalog,
identifier: Identifier,
options: CaseInsensitiveStringMap,
changelog: ChangelogTable,
output: Seq[AttributeReference],
context: Context)
extends V2Reference {
override def newInstance() = copy(output = output.map(_.newInstance()))
}
Context and its cases (TemporaryViewContext, TransactionContext,
WriteTargetContext) move to a V2Reference companion — nothing about them is
table-specific; resolveChangelogReference already reads ref.context.cacheable.
Dispatch becomes:
def resolveReference(ref: V2Reference): LogicalPlan = {
val relation = ref match {
case tableRef: V2TableReference => resolveTableReference(tableRef)
case changelogRef: V2ChangelogReference =>
resolveChangelogReference(changelogRef)
}
cloneWithPlanId(relation, ref.getTagValue(LogicalPlan.PLAN_ID_TAG))
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]