'spark structure streaming's committedOffsets is empty

I am using spark3's structure streaming to consumer data from Kafka, and I set the starting offset to "earliest". when I use the below spark code to get offset from a spark. the committed offsets are empty, Will anyone tell me the reason and how to resolve it? thanks

val commitedOffsets = sparkSession.sessionState
  .streamingQueryManager
  .active(0)
  .asInstanceOf[StreamingQueryWrapper]
  .streamingQuery
  .committedOffsets
  .values
  .head
  .json()

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source