This topic describes how to use the CONV function to perform base conversation on numeric values or characters.
Limits
This function is supported only in Realtime Compute for Apache Flink that uses Ververica Runtime (VVR) 3.0.0 or later.
The CONV() function works with the 64-bit precision.
Syntax
VARCHAR CONV(BIGINT number, INT FROM_BASE, INT TO_BASE)
or
VARCHAR CONV(VARCHAR number, INT FROM_BASE, INT TO_BASE)
Input parameters
Parameter | Data type | Description |
number | BIGINT or VARCHAR | The number that you want to convert. The value of this parameter is of the STRING or NUMBER data type. Note If the value of the number parameter is NULL or an invalid character, NULL is returned. |
FROM_BASE | INT | The current base of a number. Valid values: [2, 36]. |
TO_BASE | INT | The destination base of the number. Positive valid values: [2, 36]. Negative valid values: [-36, -2]. |
Example
Test data
id(INT)
x(BIGINT)
y (VARCHAR)
1
12
'12'
2
10
'10'
3
0
'test'
4
NULL
NULL
Test statements
SELECT id, conv(x, 10, 16) as var1, conv(y, 10, 2) as var2 FROM T1;
Test results
id(INT)
var1(VARCHAR)
var2(VARCHAR)
1
C
1100
2
A
1010
3
0
NULL
4
NULL
NULL