format_readable_size¶
format_readable_size(size_in_bytes)
Description¶
Return a human-readable string representation of a byte size.
Converts byte counts into compact format with KB, MB, GB, TB suffixes
(e.g. 67000 → 65.4 KiB, 1073741824 → 1.0 GiB).
Usage¶
Call or Deploy format_readable_size ?
Call format_readable_size directly
The easiest way to use bigfunctions
format_readable_sizefunction is deployed in 39 public datasets for all of the 39 BigQuery regions.- It can be called by anyone. Just copy / paste examples below in your BigQuery console. It just works!
- (You need to use the dataset in the same region as your datasets otherwise you may have a function not found error)
Public BigFunctions Datasets
| Region | Dataset |
|---|---|
eu |
bigfunctions.eu |
us |
bigfunctions.us |
europe-west1 |
bigfunctions.europe_west1 |
asia-east1 |
bigfunctions.asia_east1 |
| ... | ... |
Deploy format_readable_size in your project
Why deploy?
- You may prefer to deploy
format_readable_sizein your own project to build and manage your own catalog of functions. - This is particularly useful if you want to create private functions (for example calling your internal APIs).
- Get started by reading the framework page
Deployment
format_readable_size function can be deployed with:
pip install bigfunctions
bigfun get format_readable_size
bigfun deploy format_readable_size
Examples¶
1. Byte value smaller than 1 KiB
select bigfunctions.eu.format_readable_size(512)
select bigfunctions.us.format_readable_size(512)
select bigfunctions.europe_west1.format_readable_size(512)
+---------------+
| readable_size |
+---------------+
| 512 B |
+---------------+
2. Byte value converted to KiB
select bigfunctions.eu.format_readable_size(67000)
select bigfunctions.us.format_readable_size(67000)
select bigfunctions.europe_west1.format_readable_size(67000)
+---------------+
| readable_size |
+---------------+
| 65.4 KiB |
+---------------+
3. Byte value converted to GiB
select bigfunctions.eu.format_readable_size(1073741824)
select bigfunctions.us.format_readable_size(1073741824)
select bigfunctions.europe_west1.format_readable_size(1073741824)
+---------------+
| readable_size |
+---------------+
| 1.0 GiB |
+---------------+
Need help or Found a bug?
Get help using format_readable_size
The community can help! Engage the conversation on Slack
We also provide professional suppport.
Report a bug about format_readable_size
If the function does not work as expected, please
- report a bug so that it can be improved.
- or open the discussion with the community on Slack.
We also provide professional suppport.