AngersZhuuuu opened a new pull request #28860:
URL: https://github.com/apache/spark/pull/28860


   ### What changes were proposed in this pull request?
   For data nest.json
   ```
   {"a": [{"b": [{"c": [1,2]}]}]}
   {"a": [{"b": [{"c": [1]}, {"c": [2]}]}]}
   ```
   run with 
   ```
   val df: DataFrame = spark.read.json(testFile("nest-data.json"))
   df.createTempView("nest_table")
   sql("select a.b.c from nest_table").show()
   ```
   will got error 
   ````
   org.apache.spark.sql.AnalysisException: cannot resolve 
'nest_table.`a`.`b`['c']' due to data type mismatch: argument 2 requires 
integral type, however, ''c'' is of string type.; line 1 pos 7;
   'Project [a#6.b[c] AS c#8|#6.b[c] AS c#8]
   +- SubqueryAlias `nest_table`
   +- Relationa#6 json
   ```
   
   this is because after resolve a.b, it construct GetArrayStructField from a#
   result with type ArrayType(ArrayType(StructType)), then it can't be extract 
through current ExtractValue method
   
   Support extract StructField form nested Array-Struct  combination
   
   
   
   ### Why are the changes needed?
   Support More use case 
   
   
   ### Does this PR introduce _any_ user-facing change?
   No
   
   ### How was this patch tested?
   Added UT
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to