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:ย 

INSERT OVERWRITE DIRECTORY

subhadeep
New Contributor II

I am using this query to create a csv in a volume named test_volsrr that i created

INSERT OVERWRITE DIRECTORY '/Volumes/DATAMAX_DATABRICKS/staging/test_volsrr'
USING CSV
OPTIONS ('delimiter' = ',', 'header' = 'true')
SELECT * FROM staging.extract1gb
DISTRIBUTE BY COALESCE(1);
 
i added DISTRIBUTE BY COALESCE(1) so that a single csv gets generated instead of multiple csvs , the size of extract1gb table is 1gb but the csv which is getting created is around 230gb , due to this it is taking more than an hour to execute . Can some pls explain this issue and a solution to generate the csv of optimal size so that execution becomes faster . I dont want to use pyspark .
2 REPLIES 2

Isi
New Contributor II

Hey,

The issue youโ€™re facing with the CSV file size being significantly larger than the original table is likely due to the serialization and formatting overhead when exporting the data. A good way to verify this would be to try exporting the same dataset using the Parquet format, which is more optimized for storage and performance.

You can also enable compression or export only the necessary columns to minimize the data volume being written

If you think this option is correct, please give it a ๐Ÿ‘

๐Ÿ™‚



NandiniN
Databricks Employee
Databricks Employee

The DISTRIBUTE BY COALESCE(1) clause is intended to reduce the number of output files to one. However, this can lead to inefficiencies and large file sizes because it forces all data to be processed by a single task, which can cause memory and performance issues. Instead of using COALESCE(1), consider using REPARTITION(1). This can help in better distributing the data and reducing the file size.

Applying compression to the CSV file can significantly reduce its size. You can use the compression option to specify the desired compression codec (e.g., gzip๐Ÿ˜ž

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