Skip to main content

PARSE_DATA_SIZE

Description

Parse a string in the format of "value + unit" and convert the value into a number, where the value represents a fractional amount of the unit.

If the input parameter is invalid, an error will be raised. The maximum return value is Int128 Max.

Data Storage Unit Table

UnitDescriptionValue
BBytes1
kBKilobytes1024
MBMegabytes1024²
GBGigabytes1024³
TBTerabytes1024⁴
PBPetabytes1024⁵
EBExabytes1024⁶
ZBZettabytes1024⁷
YBYottabytes1024⁸

Syntax

PARSE_DATA_SIZE(<str>)

Parameters

ParameterDescription
<str>The value is to be calculated

Return Value

The return number value represents a fractional amount of the unit.

Example

SELECT parse_data_size('1B');
+-----------------------+
| parse_data_size('1B') |
+-----------------------+
| 1 |
+-----------------------+
SELECT parse_data_size('1kB');
+------------------------+
| parse_data_size('1kB') |
+------------------------+
| 1024 |
+------------------------+
SELECT parse_data_size('2.3MB');
+--------------------------+
| parse_data_size('2.3MB') |
+--------------------------+
| 2411724 |
+--------------------------+