Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature(function): add scalar function humanize #5035

Closed
sundy-li opened this issue Apr 24, 2022 · 4 comments · Fixed by #5073
Closed

Feature(function): add scalar function humanize #5035

sundy-li opened this issue Apr 24, 2022 · 4 comments · Fixed by #5073
Assignees
Labels
C-feature Category: feature C-function Category: Functions community-take good first issue Category: good first issue

Comments

@sundy-li
Copy link
Member

sundy-li commented Apr 24, 2022

Summary

Description for this feature.

Context:

databend > select sum(length(stack_trace)), sum( length(session_settings) ), sum(length(query_text )) from system.query_log;
+--------------------------+-------------------------------+-------------------------+
| sum(length(stack_trace)) | sum(length(session_settings)) | sum(length(query_text)) |
+--------------------------+-------------------------------+-------------------------+
|                        0 |                          6375 |                     734 |
+--------------------------+-------------------------------+-------------------------+

We can add humanize function to display the size for better reading.

  • Function: humanize
  • ReturnType: String
  • Example:
databend > select humanize(1024);

+------------+
|  humanize(1024) |
+------------+
|       1.00 KiB |

@sundy-li sundy-li added C-feature Category: feature good first issue Category: good first issue C-function Category: Functions labels Apr 24, 2022
@cadl
Copy link
Contributor

cadl commented Apr 24, 2022

/assignme

@cadl
Copy link
Contributor

cadl commented Apr 27, 2022

@sundy-li

The helper convert_byte_size(num: f64) return KB/MB not KiB/MiB.
Is ok to return KB not KiB for humanize?

@cadl
Copy link
Contributor

cadl commented Apr 27, 2022

The term "humanize" may not only fit in byte size.
How about creating two functions? The humanize_size convert 1000 to "1KB", and humanize_number convert 1000 to "1 thousand"?

@sundy-li
Copy link
Member Author

sundy-li commented Apr 27, 2022

The helper convert_byte_size(num: f64) return KB/MB not KiB/MiB.
Is ok to return KB not KiB for humanize?

It's ok. humanize_size + humanize_number is good idea, we can use generic function template to implement these two.

@mergify mergify bot closed this as completed in #5073 May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: feature C-function Category: Functions community-take good first issue Category: good first issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants