Cloud Technology

Choosing the right numeric precision for Data Science features in Snowflake?

MI Asked by Michelle Reed · 15-08-2023
▲ 0 upvotes 14,148 views 0 comments
The question

I am setting up a data pipeline to Snowflake for our Data Science team. I have columns currently defined as FLOAT, but our analysts are asking for NUMBER(38,0) for certain ID fields. Does the choice of numeric data type affect the micro-partitioning or query speed in Snowflake? I want to ensure the data types are optimized for both storage and analytical performance. 

3 answers

▲ 0
AN
Answered on 22-08-2023

Snowflake is great because it handles the storage efficiently regardless, but defining the precision helps the BI tools interpret the data correctly. 

MI 23-08-2023

Good point, Angela. Our Power BI reports were showing IDs with commas and decimals until we fixed the data type in the warehouse.

▲ 0
DO
Answered on 17-08-2024

In Snowflake, the choice between FLOAT and NUMBER is significant. FLOAT is a 64-bit double-precision floating-point, while NUMBER is a fixed-point type. For IDs or any value where exactness is required, always use NUMBER. Snowflake is highly optimized for "compressed" storage, so if you use a smaller precision, like NUMBER(10,0), it won't necessarily save a ton of disk space because of the way it stores data in micro-partitions, but it serves as a crucial constraint for your data quality. For machine learning features like weights or probabilities, FLOAT is perfectly fine and often faster for mathematical computations.

▲ 0
KE
Answered on 19-08-2024

Are you seeing any "bottlenecks" when joining these ID columns if they are set as FLOAT versus NUMBER? 

ED 21-08-2023

Kenneth, we did see some weirdness where a join failed because of scientific notation in the FLOAT column. That's a classic issue. Joining on FLOAT is risky because 10000 might be stored as 10000.00000000001, failing the equality check. For Join keys, always, always use an integer-based NUMBER type to ensure the joins are deterministic and fast.

Share your thoughts

Your email address will not be published. Required fields are marked (*)

Still have questions? Schedule a free counselling session

Our experts are ready to help you with any questions about courses, admissions, or career paths. Get personalized guidance from industry professionals.

Book Free Session

Book Free Session