Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
trigger(availableNow = True)
This trigger option processes all data currently available (files visible at start or discovered during the run) as a sequence of micro‑batches, then stops automatically which is perfect for catch‑ups, daily slices, or “drain the backlog” jobs.In Microsoft Fabric, using streaming for batch via availableNow can lower CU consumption compared to always‑on streaming (since compute isn’t permanently running).
Putting it all together in the code sample below .This can be created as a Fabric Notebook and scheduled using Fabric Pipelines
# Define your schema
from pyspark.sql.types import StructField,StructType,StringType,IntegerType,FloatType
file_location = <full file path>
checkpoint_location = <checkpoint path>
data_schema = StructType([
StructField("vendor_id", StringType(), True),
StructField("rate_code", IntegerType(), True),
StructField("passenger_count", IntegerType(), True),
StructField("trip_time_in_secs",IntegerType(),True),
StructField("trip_distance",FloatType(),True),
StructField("payment_type",StringType(),True),
StructField("fare_amount",FloatType(),True)
# Add all your columns here
])
df_stream = (
myspark.readStream
.format("csv")
.option("Header",True)
.schema(data_schema)
.load(f"{file_location}/*.csv")
)
def write_to_table(batch_df,batch_id):
batch_df.write.mode("append").saveAsTable("taxi_data_stream_triggermode")
query=(
df_stream.writeStream
.foreachBatch(write_to_table)
.option("checkpointLocation",f"{checkpoint_location}/")
.trigger(availableNow=True)
.start()
)
print(query.status)
print(query.recentProgress)
Have you used or encountered specific use-case of structured streaming do comment on the post and share the knowledge with the wider community.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.