Github user liancheng commented on a diff in the pull request: https://github.com/apache/spark/pull/14957#discussion_r84422376 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileSourceStrategy.scala --- @@ -126,4 +136,52 @@ object FileSourceStrategy extends Strategy with Logging { case _ => Nil } + + private def generateStructFieldsContainsNesting(projects: Seq[Expression], + totalSchema: StructType) : Seq[StructField] = { + def generateStructField(curField: List[String], + node: Expression) : Seq[StructField] = { + node match { + case ai: GetArrayItem => + // Here we drop the previous for simplify array and map support. + // Same strategy in GetArrayStructFields and GetMapValue + generateStructField(List.empty[String], ai.child) + case asf: GetArrayStructFields => + generateStructField(List.empty[String], asf.child) + case mv: GetMapValue => + generateStructField(List.empty[String], mv.child) + case attr: AttributeReference => + Seq(getFieldRecursively(totalSchema, attr.name :: curField)) + case sf: GetStructField => + generateStructField(sf.name.get :: curField, sf.child) + case _ => + if (node.children.nonEmpty) { + node.children.flatMap(child => generateStructField(curField, child)) + } else { + Seq.empty[StructField] + } + } + } + + def getFieldRecursively(totalSchema: StructType, + name: List[String]): StructField = { --- End diff -- And this.
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org