Updated on 2024-11-29 GMT+08:00

String Cut

Overview

String Cut: cuts existing fields to generate new fields.

Input and Output

  • Input: fields to be truncated
  • Output: new fields generated after truncation

Description

Table 1 Operator parameters

Parameter

Description

Type

Mandatory

Default Value

Fields to be cut

Information about a cut field:

  • input field name: Names of the input fields. Set this parameter to the names of the fields generated in the previous conversion step.
  • output field name: Names of the configured output fields.
  • start position: start position of the cut, starting from No. 1.
  • end position: end position of the field to be cut. If the length of the string cannot be determined, set this parameter to -1, indicating the end of a field to be cut.
  • output field type: type of an output field.
  • output field length: field length. If the actual field value is excessively long, the value is cut based on the configured length. If output field type is CHAR, spaces are added to the field value for supplement if the actual length actual field value length is less than the configured length. If output field type is VARCHAR, no space is added to the field value for supplement if the actual field value length is less than the configured length.

map

Yes

None

Data Processing Rule

  • Use the start position and end position to cut the original field value and generate a new field.
  • If the end position is -1, it indicates the end of a field. In other cases, the end position cannot be smaller than the start position.
  • If the start or end position of the string to be cut is greater than the length of the input field, the current line becomes dirty data.

Example

Use the CSV File Input operator to generate two fields: A and B.

The source file is as follows:

abcd,product
FusionInsight,Bigdata

After String Cut operator is configured, fields C and D are generated.

After the conversion, the following fields are generated:

abcd,product,abc,prod
FusionInsight,Bigdata,Fus,Bigd