Convert base(进制转换(Convert base))¶
Supported in: Batch, Streaming
Convert a number (or it string representation) from one base to another.
Expression categories: Binary, Cast, Numeric
Declared arguments¶
- Expression: Column to convert base.
Expression\ - From base: Convert from base.
Literal\ - To base: Convert to base.
Literal\
Output type: String
Examples¶
Example 1: Base case¶
Argument values:
- Expression: 4A801
- From base: 16
- To base: 10
Output: 305153
Example 2: Base case¶
Argument values:
- Expression: 8
- From base: 10
- To base: 2
Output: 1000
Example 3: Null case¶
Argument values:
- Expression:
input - From base: 10
- To base: 16
| input | Output |
|---|---|
| null | null |
Example 4: Edge case¶
Description: When input is made of characters that are outside the base of the given 'from base', only the leading characters up to the first out of base character is considered.
Argument values:
- Expression:
input - From base: 2
- To base: 10
| input | Output |
|---|---|
| 123 | 1 |
| 213 | 0 |
| 1032 | 2 |
中文翻译¶
进制转换(Convert base)¶
支持:批处理(Batch)、流处理(Streaming)
将一个数字(或其字符串表示形式)从一种进制转换为另一种进制。
表达式类别: 二进制(Binary)、类型转换(Cast)、数值(Numeric)
声明参数¶
- 表达式(Expression): 需要转换进制的列。
表达式类型:Byte | Integer | Long | Short | String - 从进制(From base): 转换前的进制。
字面量类型:Integer - 到进制(To base): 转换后的进制。
字面量类型:Integer
输出类型: String
示例¶
示例 1:基本情形¶
参数值:
- 表达式: 4A801
- 从进制: 16
- 到进制: 10
输出: 305153
示例 2:基本情形¶
参数值:
- 表达式: 8
- 从进制: 10
- 到进制: 2
输出: 1000
示例 3:空值情形¶
参数值:
- 表达式:
input - 从进制: 10
- 到进制: 16
| input | 输出 |
|---|---|
| null | null |
示例 4:边界情形¶
描述: 当输入中包含超出给定"从进制"范围的字符时,仅考虑从开头到第一个超出进制范围的字符之前的部分。
参数值:
- 表达式:
input - 从进制: 2
- 到进制: 10
| input | 输出 |
|---|---|
| 123 | 1 |
| 213 | 0 |
| 1032 | 2 |