Github user hvanhovell commented on a diff in the pull request:
https://github.com/apache/spark/pull/16168#discussion_r91064615
--- Diff:
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala ---
@@ -126,6 +146,55 @@ private[hive] class HiveMetastoreCatalog(sparkSession:
SparkSession) extends Log
}
}
+ /**
+ * Apply Projection on unresolved logical plan to:
+ * 1. Omit the columns which are not referenced by the view;
+ * 2. Reorder the columns to keep the same order with the view;
+ */
+ private def withProjection(plan: LogicalPlan, schema: StructType):
LogicalPlan = {
+ // All fields in schema should exist in plan.schema, or we should
throw an AnalysisException
+ // to notify the underlying schema has been changed.
+ if (schema.fields.forall { field =>
+ plan.schema.fields.exists(other => compareStructField(field,
other))}) {
+ val output = schema.fields.map { field =>
+ plan.output.find { expr =>
+ expr.name == field.name && expr.dataType ==
field.dataType}.getOrElse(
--- End diff --
This is a case-sensitive match; spark's default is case-insensitive
matching. Please use a resolver for such a check.
A more general thought is that we really should leverage the analyzer's
capabilities here.
---
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]