@@ -23,13 +23,13 @@ import org.apache.spark.sql.catalyst.expressions._
2323import org .apache .spark .sql .catalyst .expressions .objects .StaticInvoke
2424import org .apache .spark .sql .internal .SQLConf
2525import org .apache .spark .sql .internal .types .StringTypeWithCollation
26- import org .apache .spark .sql .types .{BinaryType , BooleanType , DataTypes , StringType }
26+ import org .apache .spark .sql .types .{BinaryType , BooleanType , DataTypes , MapType , StringType }
2727
2828import org .apache .comet .CometSparkSessionExtensions .withInfo
2929import org .apache .comet .expressions .{CometCast , CometEvalMode }
3030import org .apache .comet .serde .{CommonStringExprs , Compatible , ExprOuterClass , Incompatible }
3131import org .apache .comet .serde .ExprOuterClass .{BinaryOutputStyle , Expr }
32- import org .apache .comet .serde .QueryPlanSerde .exprToProtoInternal
32+ import org .apache .comet .serde .QueryPlanSerde .{ exprToProtoInternal , optExprWithInfo , scalarFunctionExprToProto }
3333
3434/**
3535 * `CometExprShim` acts as a shim for parsing expressions from different Spark versions.
@@ -103,6 +103,17 @@ trait CometExprShim extends CommonStringExprs {
103103 None
104104 }
105105
106+ case expr : MapSort =>
107+ val keyType = expr.base.dataType.asInstanceOf [MapType ].keyType
108+ if (! RowOrdering .isOrderable(keyType)) {
109+ withInfo(expr, s " map_sort requires orderable key type, got: $keyType" )
110+ return None
111+ }
112+
113+ val childExpr = exprToProtoInternal(expr.base, inputs, binding)
114+ val mapSortScalarExpr = scalarFunctionExprToProto(" map_sort" , childExpr)
115+ optExprWithInfo(mapSortScalarExpr, expr, expr.children: _* )
116+
106117 case _ => None
107118 }
108119 }
0 commit comments