-
Notifications
You must be signed in to change notification settings - Fork 761
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(function): Add
humanize_size
and humanize_number
functions
- Loading branch information
Showing
8 changed files
with
165 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
docs/doc/30-reference/20-functions/120-other-functions/humanize-number.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
title: HUMANIZE_NUMBER | ||
--- | ||
|
||
Returns a readable number. | ||
|
||
## Syntax | ||
|
||
```sql | ||
HUMANIZE_NUMBER(x); | ||
``` | ||
|
||
## Arguments | ||
|
||
| Arguments | Description | | ||
|-----------|----------------------------| | ||
| x | The numerical size. | | ||
|
||
|
||
## Return Type | ||
|
||
String. | ||
|
||
## Examples | ||
|
||
```sql | ||
SELECT HUMANIZE_NUMBER(1000 * 1000) | ||
+-------------------------+ | ||
| HUMANIZE_NUMBER((1000 * 1000)) | | ||
+-------------------------+ | ||
| 1 million | | ||
+-------------------------+ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,12 @@ | |
-1 KB | ||
0 B | ||
NULL | ||
1 | ||
1 million | ||
1 billion | ||
1 trillion | ||
1 quadrillion | ||
1000 quadrillion | ||
-1000 | ||
0 | ||
NULL |
33 changes: 21 additions & 12 deletions
33
tests/suites/0_stateless/02_function/02_0055_function_strings_humanize.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
SELECT HUMANIZE(1000); | ||
SELECT HUMANIZE(1000000); | ||
SELECT HUMANIZE(1000000000); | ||
SELECT HUMANIZE(1000000000000); | ||
SELECT HUMANIZE(1000000000000000); | ||
SELECT HUMANIZE(1000000000000000000); | ||
SELECT HUMANIZE(1000000000000000000000); | ||
SELECT HUMANIZE(1000000000000000000000000); | ||
SELECT HUMANIZE(1000000000000000000000000000); | ||
SELECT HUMANIZE(-1000); | ||
SELECT HUMANIZE(0); | ||
SELECT HUMANIZE(NULL); | ||
SELECT HUMANIZE_SIZE(1000); | ||
SELECT HUMANIZE_SIZE(1000000); | ||
SELECT HUMANIZE_SIZE(1000000000); | ||
SELECT HUMANIZE_SIZE(1000000000000); | ||
SELECT HUMANIZE_SIZE(1000000000000000); | ||
SELECT HUMANIZE_SIZE(1000000000000000000); | ||
SELECT HUMANIZE_SIZE(1000000000000000000000); | ||
SELECT HUMANIZE_SIZE(1000000000000000000000000); | ||
SELECT HUMANIZE_SIZE(1000000000000000000000000000); | ||
SELECT HUMANIZE_SIZE(-1000); | ||
SELECT HUMANIZE_SIZE(0); | ||
SELECT HUMANIZE_SIZE(NULL); | ||
SELECT HUMANIZE_NUMBER(1); | ||
SELECT HUMANIZE_NUMBER(1000); | ||
SELECT HUMANIZE_NUMBER(1000000); | ||
SELECT HUMANIZE_NUMBER(1000000000); | ||
SELECT HUMANIZE_NUMBER(1000000000000); | ||
SELECT HUMANIZE_NUMBER(1000000000000000); | ||
SELECT HUMANIZE_NUMBER(-1000); | ||
SELECT HUMANIZE_NUMBER(0); | ||
SELECT HUMANIZE_NUMBER(NULL); |