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;

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now