cancel
Showing results for 
Search instead for 
Did you mean: 
Community Platform Discussions
Connect with fellow community members to discuss general topics related to the Databricks platform, industry trends, and best practices. Share experiences, ask questions, and foster collaboration within the community.
cancel
Showing results for 
Search instead for 
Did you mean: 

Can I load the files based on the data in my table as variable without iterating through each row?

zll_0091
New Contributor III

Hi,

I have created this table which contains the data that I need for my source path and target table. 

zll_0091_2-1722958875477.png

source_path: /data/customer/sid={sid}/abc=1/attr_provider={attr_prov}/source_data_provider_code={src_prov}/

zll_0091_1-1722958858553.png

So basically, the value of each row are connected so I don't need to iterate all over them anymore. I wan to load only the files that are in the folder that is greater than my max(key). These is the sample structure of my storage:

zll_0091_3-1722958975973.png

For this example, using the first row of my table, my code should only load the files from folder10023 & folder10054.

Is there any way not to iterate through each rows of the table? 

1 REPLY 1

Kaniz_Fatma
Community Manager
Community Manager

Hi @zll_0091, To efficiently load only the necessary files without manually iterating through each row of your table, you can use Spark's DataFrame operations. First, read your table into a DataFrame and determine the maximum key value. Then, filter the folders based on this key and load the files from the filtered folders. This approach avoids manual row iteration and streamlines the file-loading process. 

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