@@ -26,7 +26,7 @@ import org.scalatest.FunSuite
2626import org .scalatest .Matchers ._
2727
2828import org .apache .spark .sql .catalyst .CatalystTypeConverters
29- import org .apache .spark .sql .catalyst .analysis .UnresolvedGetField
29+ import org .apache .spark .sql .catalyst .analysis .UnresolvedExtractValue
3030import org .apache .spark .sql .catalyst .dsl .expressions ._
3131import org .apache .spark .sql .catalyst .expressions .mathfuncs ._
3232import org .apache .spark .sql .types ._
@@ -891,57 +891,55 @@ class ExpressionEvaluationSuite extends ExpressionEvaluationBaseSuite {
891891 val typeMap = MapType (StringType , StringType )
892892 val typeArray = ArrayType (StringType )
893893
894- checkEvaluation(MapOrdinalGetField (BoundReference (3 , typeMap, true ),
894+ checkEvaluation(GetMapValue (BoundReference (3 , typeMap, true ),
895895 Literal (" aa" )), " bb" , row)
896- checkEvaluation(MapOrdinalGetField (Literal .create(null , typeMap), Literal (" aa" )), null , row)
896+ checkEvaluation(GetMapValue (Literal .create(null , typeMap), Literal (" aa" )), null , row)
897897 checkEvaluation(
898- MapOrdinalGetField (Literal .create(null , typeMap),
899- Literal .create(null , StringType )), null , row)
900- checkEvaluation(MapOrdinalGetField (BoundReference (3 , typeMap, true ),
898+ GetMapValue (Literal .create(null , typeMap), Literal .create(null , StringType )), null , row)
899+ checkEvaluation(GetMapValue (BoundReference (3 , typeMap, true ),
901900 Literal .create(null , StringType )), null , row)
902901
903- checkEvaluation(ArrayOrdinalGetField (BoundReference (4 , typeArray, true ),
902+ checkEvaluation(GetArrayItem (BoundReference (4 , typeArray, true ),
904903 Literal (1 )), " bb" , row)
905- checkEvaluation(ArrayOrdinalGetField (Literal .create(null , typeArray), Literal (1 )), null , row)
904+ checkEvaluation(GetArrayItem (Literal .create(null , typeArray), Literal (1 )), null , row)
906905 checkEvaluation(
907- ArrayOrdinalGetField (Literal .create(null , typeArray),
908- Literal .create(null , IntegerType )), null , row)
909- checkEvaluation(ArrayOrdinalGetField (BoundReference (4 , typeArray, true ),
906+ GetArrayItem (Literal .create(null , typeArray), Literal .create(null , IntegerType )), null , row)
907+ checkEvaluation(GetArrayItem (BoundReference (4 , typeArray, true ),
910908 Literal .create(null , IntegerType )), null , row)
911909
912- def quickBuildGetField (expr : Expression , fieldName : String ): GetField = {
910+ def getStructField (expr : Expression , fieldName : String ): ExtractValue = {
913911 expr.dataType match {
914912 case StructType (fields) =>
915913 val field = fields.find(_.name == fieldName).get
916- SimpleStructGetField (expr, field, fields.indexOf(field))
914+ GetStructField (expr, field, fields.indexOf(field))
917915 }
918916 }
919917
920- def resolveGetField (u : UnresolvedGetField ): GetField = {
921- GetField (u.child, u.fieldExpr , _ == _)
918+ def quickResolve (u : UnresolvedExtractValue ): ExtractValue = {
919+ ExtractValue (u.child, u.extraction , _ == _)
922920 }
923921
924- checkEvaluation(quickBuildGetField (BoundReference (2 , typeS, nullable = true ), " a" ), " aa" , row)
925- checkEvaluation(quickBuildGetField (Literal .create(null , typeS), " a" ), null , row)
922+ checkEvaluation(getStructField (BoundReference (2 , typeS, nullable = true ), " a" ), " aa" , row)
923+ checkEvaluation(getStructField (Literal .create(null , typeS), " a" ), null , row)
926924
927925 val typeS_notNullable = StructType (
928926 StructField (" a" , StringType , nullable = false )
929927 :: StructField (" b" , StringType , nullable = false ) :: Nil
930928 )
931929
932- assert(quickBuildGetField (BoundReference (2 ,typeS, nullable = true ), " a" ).nullable === true )
933- assert(quickBuildGetField (BoundReference (2 , typeS_notNullable, nullable = false ), " a" ).nullable
930+ assert(getStructField (BoundReference (2 ,typeS, nullable = true ), " a" ).nullable === true )
931+ assert(getStructField (BoundReference (2 , typeS_notNullable, nullable = false ), " a" ).nullable
934932 === false )
935933
936- assert(quickBuildGetField (Literal .create(null , typeS), " a" ).nullable === true )
937- assert(quickBuildGetField (Literal .create(null , typeS_notNullable), " a" ).nullable === true )
934+ assert(getStructField (Literal .create(null , typeS), " a" ).nullable === true )
935+ assert(getStructField (Literal .create(null , typeS_notNullable), " a" ).nullable === true )
938936
939- checkEvaluation(resolveGetField (' c .map(typeMap).at(3 ).getItem(" aa" )), " bb" , row)
940- checkEvaluation(resolveGetField (' c .array(typeArray.elementType).at(4 ).getItem(1 )), " bb" , row)
941- checkEvaluation(resolveGetField (' c .struct(typeS).at(2 ).getField(" a" )), " aa" , row)
937+ checkEvaluation(quickResolve (' c .map(typeMap).at(3 ).getItem(" aa" )), " bb" , row)
938+ checkEvaluation(quickResolve (' c .array(typeArray.elementType).at(4 ).getItem(1 )), " bb" , row)
939+ checkEvaluation(quickResolve (' c .struct(typeS).at(2 ).getField(" a" )), " aa" , row)
942940 }
943941
944- test(" error message of GetField " ) {
942+ test(" error message of ExtractValue " ) {
945943 val structType = StructType (StructField (" a" , StringType , true ) :: Nil )
946944 val arrayStructType = ArrayType (structType)
947945 val arrayType = ArrayType (StringType )
@@ -952,7 +950,7 @@ class ExpressionEvaluationSuite extends ExpressionEvaluationBaseSuite {
952950 fieldDataType : DataType ,
953951 errorMesage : String ): Unit = {
954952 val e = intercept[org.apache.spark.sql.AnalysisException ] {
955- GetField (
953+ ExtractValue (
956954 Literal .create(null , childDataType),
957955 Literal .create(null , fieldDataType),
958956 _ == _)
@@ -963,7 +961,7 @@ class ExpressionEvaluationSuite extends ExpressionEvaluationBaseSuite {
963961 checkErrorMessage(structType, IntegerType , " Field name should be String Literal" )
964962 checkErrorMessage(arrayStructType, BooleanType , " Field name should be String Literal" )
965963 checkErrorMessage(arrayType, StringType , " Array index should be integral type" )
966- checkErrorMessage(otherType, StringType , " Can't get field on " )
964+ checkErrorMessage(otherType, StringType , " Can't extract value from " )
967965 }
968966
969967 test(" arithmetic" ) {
0 commit comments