Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/17015#discussion_r102611404
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/interface.scala
---
@@ -349,36 +350,44 @@ object CatalogTypes {
/**
- * An interface that is implemented by logical plans to return the
underlying catalog table.
- * If we can in the future consolidate SimpleCatalogRelation and
MetastoreRelation, we should
- * probably remove this interface.
+ * A [[LogicalPlan]] that represents a table.
*/
-trait CatalogRelation {
- def catalogTable: CatalogTable
- def output: Seq[Attribute]
-}
+case class CatalogRelation(
+ tableMeta: CatalogTable,
+ dataCols: Seq[Attribute],
+ partitionCols: Seq[Attribute]) extends LeafNode with
MultiInstanceRelation {
+ assert(tableMeta.identifier.database.isDefined)
+ // The partition column should always appear after data columns.
+ override def output: Seq[Attribute] = dataCols ++ partitionCols
-/**
- * A [[LogicalPlan]] that wraps [[CatalogTable]].
- *
- * Note that in the future we should consolidate this and
HiveCatalogRelation.
- */
-case class SimpleCatalogRelation(
- metadata: CatalogTable)
- extends LeafNode with CatalogRelation {
-
- override def catalogTable: CatalogTable = metadata
-
- override lazy val resolved: Boolean = false
-
- override val output: Seq[Attribute] = {
- val (partCols, dataCols) = metadata.schema.toAttributes
- // Since data can be dumped in randomly with no validation,
everything is nullable.
-
.map(_.withNullability(true).withQualifier(Some(metadata.identifier.table)))
- .partition { a =>
- metadata.partitionColumnNames.contains(a.name)
- }
- dataCols ++ partCols
+ def isPartitioned: Boolean = partitionCols.nonEmpty
+
+ override def equals(relation: Any): Boolean = relation match {
+ case other: CatalogRelation => tableMeta == other.tableMeta && output
== other.output
+ case _ => false
+ }
+
+ override def hashCode(): Int = {
+ Objects.hashCode(tableMeta.identifier, output)
}
+
+ /** Only compare table identifier. */
+ override def sameResult(plan: LogicalPlan): Boolean = {
+ plan.canonicalized match {
+ case other: CatalogRelation => tableMeta.identifier ==
other.tableMeta.identifier
+ case _ => false
+ }
+ }
--- End diff --
```Scala
override lazy val cleanArgs: Seq[Any] = Seq(tableMeta)
```
We did the same thing in the `LogicalRelation`. I think we need to do the
same thing here. Then, we do not need to implement `sameResult` for
`SubqueryAlias`. We always removed `SubqueryAlias` in `sameResult`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]