Github user uncleGen commented on a diff in the pull request:
https://github.com/apache/spark/pull/17141#discussion_r104073290
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/statefulOperators.scala
---
@@ -397,3 +402,110 @@ object StreamingDeduplicateExec {
private val EMPTY_ROW =
UnsafeProjection.create(Array[DataType](NullType)).apply(InternalRow.apply(null))
}
+
+/**
+ * Physical operator for executing streaming Sampling.
+ *
+ * @param k random sample k elements.
+ */
+case class StreamingReservoirSampleExec(
+ keyExpressions: Seq[Attribute],
+ child: SparkPlan,
+ k: Int,
+ stateId: Option[OperatorStateId] = None,
+ eventTimeWatermark: Option[Long] = None,
+ outputMode: Option[OutputMode] = None)
+ extends UnaryExecNode with StateStoreWriter with WatermarkSupport {
+
+ override def requiredChildDistribution: Seq[Distribution] =
+ ClusteredDistribution(keyExpressions) :: Nil
+
+ private val enc = Encoders.STRING.asInstanceOf[ExpressionEncoder[String]]
+ private val NUM_RECORDS_IN_PARTITION =
enc.toRow("NUM_RECORDS_IN_PARTITION")
+ .asInstanceOf[UnsafeRow]
+
--- End diff --
`NUM_RECORDS_IN_PARTITION ` calculate the total number of records in
current partiton, and update at the end of sample.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]