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

Experiencing sorting problems with bigint columns

Parth2692
New Contributor II
Experiencing sorting problems with bigint columns across tables tested.
 
Example:
In the table the projectid (bigint as per schema - which is correct) yet when sorted in SQL is sorting as per a string value
 
1000903 is returned as the minimum projectid value
998401 is returned as the maximum projectid value. 
6 REPLIES 6

EktaPuri
New Contributor III

Can you send across schema of table using describe command.

Also at runtime cast it to bigint and then check.

Parth2692
New Contributor II

Parth2692_0-1749707660024.png

 

Parth2692
New Contributor II

Parth2692_1-1749707737752.png

 

EktaPuri
New Contributor III

Can you cast explicitly to bigint and check, it's kinda strange

Parth2692
New Contributor II

When I use CAST, it returns the data type as BIGINT, which is expected. However, if I'm reading directly from the Unity Catalog (UC) table, it should already return the BIGINT data type without requiring a cast. Is there a reason why this inconsistency is occurring?

EktaPuri
New Contributor III

Try running explain command  what's happening in the background, also if table is small try to write in another table and check 

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