hvanhovell commented on code in PR #40796:
URL: https://github.com/apache/spark/pull/40796#discussion_r1190203009
##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/KeyValueGroupedDataset.scala:
##########
@@ -414,3 +582,48 @@ private class KeyValueGroupedDatasetImpl[K, V, IK, IV](
udf.apply(inputEncoders.map(_ => col("*")):
_*).expr.getCommonInlineUserDefinedFunction
}
}
+
+private object KeyValueGroupedDatasetImpl {
+ def apply[K, V](
+ ds: Dataset[V],
+ kEncoder: AgnosticEncoder[K],
+ groupingFunc: V => K): KeyValueGroupedDatasetImpl[K, V, K, V] = {
+ val gf = ScalarUserDefinedFunction(
+ function = groupingFunc,
+ inputEncoders = ds.encoder :: Nil, // Using the original value and key
encoders
+ outputEncoder = kEncoder)
+ new KeyValueGroupedDatasetImpl(
+ ds.sparkSession,
+ ds.plan,
+ kEncoder,
+ kEncoder,
+ ds.encoder,
+ ds.encoder,
+ Arrays.asList(gf.apply(col("*")).expr),
+ UdfUtils.identical(),
+ () => ds.map(groupingFunc)(kEncoder))
+ }
+
+ def apply[K, V](
+ df: DataFrame,
+ kEncoder: AgnosticEncoder[K],
+ vEncoder: AgnosticEncoder[V],
+ groupingExprs: Seq[Column]): KeyValueGroupedDatasetImpl[K, V, K, V] = {
+ // Use a dummy udf to pass the K V encoders
+ val dummyGroupingFunc = ScalarUserDefinedFunction(
+ function = UdfUtils.noOp[V, K](),
Review Comment:
If we can we should get rid of this.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]