cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Autoloader maxFilesPerTrigger not working correctly

sanjay
Valued Contributor II

Hi,

am trying to apply batch size in autoloader and code is as below. But its picking all the changes in one go even if I have put maxFilesPerTrigger as 10. Appreciate any help.

(spark.readStream.format("json").schema(streamSchema)

.option("cloudFiles.backfillInterval", "1 day")

.option("cloudFiles.fetchParallelism", 100)

.option("cloudFiles.useNotification","true")

.option("cloudFiles.includeExistingFiles","true")

.option("cloudFiles.allowOverwrites",True)

.option("ignoreMissingFiles",True)

.option("maxFilesPerTrigger", 10)

.load(raw_path)

.writeStream

.option("checkpointLocation", bronze_checkpoint_path)

.trigger(once=True)

.foreachBatch(foreachBatchFunction)

.start()

.awaitTermination()

)

1 ACCEPTED SOLUTION

Accepted Solutions

Lakshay
Databricks Employee
Databricks Employee

Hi @Sanjay Jainโ€‹ , Since you have provided the trigger as once, the maxFilesPerTrigger will not take effect here. With trigger once, all the files will be read together. You need to change the trigger for this option to come into effect.

Please refer the document here :

https://docs.databricks.com/ingestion/auto-loader/options.html#common-auto-loader-options

View solution in original post

3 REPLIES 3

Lakshay
Databricks Employee
Databricks Employee

Hi @Sanjay Jainโ€‹ , Since you have provided the trigger as once, the maxFilesPerTrigger will not take effect here. With trigger once, all the files will be read together. You need to change the trigger for this option to come into effect.

Please refer the document here :

https://docs.databricks.com/ingestion/auto-loader/options.html#common-auto-loader-options

sanjay
Valued Contributor II

Thank you Lakshay

sanjay
Valued Contributor II

Hi,

This is working for autoloader and I am able to limit batch size. But in next layer, I am still getting full load. Is there any way to limit batch size. Here is my code.

(spark.readStream.format("delta")

.option("cloudFiles.useNotification","true")

.option("cloudFiles.includeExistingFiles","true")

.option("cloudFiles.allowOverwrites",True)

.option("ignoreMissingFiles",True)

.option("cloudFiles.maxFilesPerTrigger", 100)

.option("ignoreChanges","true")

.load(bronze_path)

.writeStream

.option("checkpointLocation", silver_checkpoint_path)

.trigger(processingTime="1 minute")

.foreachBatch(foreachBatchFunction)

.start()

)

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group