Github user chenghao-intel commented on a diff in the pull request:
https://github.com/apache/spark/pull/4892#discussion_r25840313
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
---
@@ -277,36 +279,6 @@ class Analyzer(catalog: Catalog,
*/
protected def containsStar(exprs: Seq[Expression]): Boolean =
exprs.exists(_.collect { case _: Star => true }.nonEmpty)
-
- /**
- * Returns the resolved `GetField`, and report error if no desired
field or over one
- * desired fields are found.
- */
- protected def resolveGetField(expr: Expression, fieldName: String):
Expression = {
- def findField(fields: Array[StructField]): Int = {
- val checkField = (f: StructField) => resolver(f.name, fieldName)
- val ordinal = fields.indexWhere(checkField)
- if (ordinal == -1) {
- throw new AnalysisException(
- s"No such struct field $fieldName in
${fields.map(_.name).mkString(", ")}")
- } else if (fields.indexWhere(checkField, ordinal + 1) != -1) {
- throw new AnalysisException(
- s"Ambiguous reference to fields
${fields.filter(checkField).mkString(", ")}")
- } else {
- ordinal
- }
- }
- expr.dataType match {
- case StructType(fields) =>
- val ordinal = findField(fields)
- StructGetField(expr, fields(ordinal), ordinal)
- case ArrayType(StructType(fields), containsNull) =>
- val ordinal = findField(fields)
- ArrayGetField(expr, fields(ordinal), ordinal, containsNull)
- case otherType =>
- throw new AnalysisException(s"GetField is not valid on fields of
type $otherType")
- }
- }
--- End diff --
Move this function into the `LogicalPlan`
---
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]