Currently, we are trying to add a new column to the incoming streaming dataframe with value from currentBatchId of StreamExecution. This is required by our use case.
Is that possible?
You can use the following UDF:
val batchUDF = udf { () =>
TaskContext.get().getLocalProperty("streaming.sql.batchId").toInt
}
Then: df.withColumn("batch", batchUDF())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With