cancel
Showing results for 
Search instead for 
Did you mean: 
Warehousing & Analytics
Engage in discussions on data warehousing, analytics, and BI solutions within the Databricks Community. Share insights, tips, and best practices for leveraging data for informed decision-making.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the size of selected rows in bytes using a single SQL query?

Akshay_Petkar
Contributor III

Hi all,

I have a table named employee in Databricks. I ran the following query to filter out rows where the salary is greater than 25000.

This query returns 10 rows. I want to find the size of these 10 rows in bytes, and I would like to calculate or retrieve this size only within the same query. How can I achieve this?

Any help would be appreciated!

1 REPLY 1

Alberto_Umana
Databricks Employee
Databricks Employee

Hi @Akshay_Petkar,

You can try with this query:

SELECT SUM(LENGTH(CAST(employee.* AS STRING))) AS total_size_in_bytes
FROM employee
WHERE salary > 25000;

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