All Products
Search
Document Center

Realtime Compute for Apache Flink:CONV

Last Updated:Mar 26, 2026

Converts a number from one base to another. CONV accepts both integer and string representations of the input number and always returns a VARCHAR result.

CONV is supported only in Realtime Compute for Apache Flink that uses Ververica Runtime (VVR) 3.0.0 or later.

Syntax

VARCHAR CONV(BIGINT number, INT FROM_BASE, INT TO_BASE)
VARCHAR CONV(VARCHAR number, INT FROM_BASE, INT TO_BASE)

Parameters

ParameterData typeDescription
numberBIGINT or VARCHARThe number to convert.
FROM_BASEINTThe base of the input number. Valid values: [2, 36].
TO_BASEINTThe base to convert to. Positive valid values: [2, 36]. Negative valid values: [-36, -2].

Returns

A VARCHAR string representing the converted number.

  • For bases above 10, letters represent digits: A = 10, B = 11, ..., Z = 35.

  • Returns NULL if number is NULL or contains characters that are invalid for the specified FROM_BASE.

  • The function operates with 64-bit precision.

Examples

Base conversion

SELECT conv('100', 2, 10);
-- 4

SELECT conv('A', 16, 10);
-- 10

NULL and invalid input

SELECT conv(NULL, 10, 16);
-- NULL

SELECT conv('test', 10, 2);
-- NULL  (invalid characters for base 10)

Table-based example

The following example uses a table T1:

id (INT)x (BIGINT)y (VARCHAR)
112'12'
210'10'
30'test'
4NULLNULL

Statement:

SELECT id, conv(x, 10, 16) AS var1, conv(y, 10, 2) AS var2
FROM T1;

Results:

idvar1var2
1C1100
2A1010
30NULL
4NULLNULL
  • Row 3: x=0 converts to 0 in any base. y='test' is not valid base-10 input, so NULL is returned.

  • Row 4: NULL input returns NULL.