Skip to main content

QUANTILE_STATE_TO_BASE64

Description

Converts a QUANTILE_STATE type to a base64 encoded string.

Syntax

QUANTILE_STATE_TO_BASE64(<quantile_state_input>)

Parameters

ParameterDescription
<quantile_state_input>Data of QUANTILE_STATE type.

Return Value

The Base64 encoded string of the QUANTILE_STATE. Returns NULL if the QUANTILE_STATE is NULL.

::: note

Since the order of elements in QUANTILE_STATE cannot be guaranteed, the base64 result generated from the same QUANTILE_STATE content is not guaranteed to be always the same, but the QUANTILE_STATE decoded by quantile_state_from_base64 is guaranteed to be the same.

:::

Examples

select quantile_state_to_base64(quantile_state_empty());
+--------------------------------------------------+
| quantile_state_to_base64(quantile_state_empty()) |
+--------------------------------------------------+
| AAAARQA= |
+--------------------------------------------------+
select quantile_state_to_base64(to_quantile_state(1, 2048));
+------------------------------------------------------+
| quantile_state_to_base64(to_quantile_state(1, 2048)) |
+------------------------------------------------------+
| AAAARQEAAAAAAADwPw== |
+------------------------------------------------------+
select
quantile_percent(
quantile_union(
quantile_state_from_base64(
quantile_state_to_base64(to_quantile_state(1, 2048))
)
),
0.5
) as nested_test;
+-------------+
| nested_test |
+-------------+
| 1 |
+-------------+
select quantile_state_to_base64(NULL);
+--------------------------------+
| quantile_state_to_base64(NULL) |
+--------------------------------+
| NULL |
+--------------------------------+