Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/16233#discussion_r93993539
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala
---
@@ -377,6 +378,36 @@ case class InsertIntoTable(
override lazy val resolved: Boolean = childrenResolved && table.resolved
}
+/** Factory for constructing new `View` nodes. */
+object View {
+ def apply(desc: CatalogTable): View = View(desc,
desc.schema.toAttributes, None)
+}
+
+/**
+ * A container for holding the view description(CatalogTable), and the
output of the view. The
+ * child will be defined if the view is defined in a Hive metastore or the
view is resolved,
+ * else it should be None.
+ * This operator will be removed at the end of analysis stage.
+ *
+ * @param desc A view description(CatalogTable) that provides necessary
information to resolve the
+ * view.
+ * @param output The output of a view operator, this is generated during
planning the view, so that
+ * we are able to decouple the output from the underlying
structure.
+ * @param child The logical plan of a view operator, it should be
non-empty if the view is defined
+ * in a Hive metastore or the view is resolved, else it
should be None.
+ */
+case class View(
+ desc: CatalogTable,
+ output: Seq[Attribute],
+ child: Option[LogicalPlan] = None) extends LogicalPlan with
MultiInstanceRelation {
+
+ override lazy val resolved: Boolean = child.exists(_.resolved)
+
+ override def children: Seq[LogicalPlan] = child.toSeq
+
+ override def newInstance(): LogicalPlan = copy(output =
output.map(_.newInstance()))
+}
--- End diff --
We also need to add `override def simpleString`, which is used for `ONE
line description of this node`. Currently, we output the whole `CatalogTable`.
---
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]