diff --git a/pkg/config/sink.go b/pkg/config/sink.go index aa755a65d8f..e959b9ebad5 100644 --- a/pkg/config/sink.go +++ b/pkg/config/sink.go @@ -221,14 +221,14 @@ func (c *CSVConfig) validateAndAdjust() error { case 0: return cerror.WrapError(cerror.ErrSinkInvalidConfig, errors.New("csv config delimiter cannot be empty")) - case 1, 2: + case 1, 2, 3: if strings.ContainsRune(c.Delimiter, CR) || strings.ContainsRune(c.Delimiter, LF) { return cerror.WrapError(cerror.ErrSinkInvalidConfig, errors.New("csv config delimiter contains line break characters")) } default: return cerror.WrapError(cerror.ErrSinkInvalidConfig, - errors.New("csv config delimiter contains more than two character, note that escape "+ + errors.New("csv config delimiter contains more than three characters, note that escape "+ "sequences can only be used in double quotes in toml configuration items.")) } diff --git a/pkg/config/sink_test.go b/pkg/config/sink_test.go index ccb606e92da..a0378f3c4d2 100644 --- a/pkg/config/sink_test.go +++ b/pkg/config/sink_test.go @@ -342,6 +342,15 @@ func TestValidateAndAdjustCSVConfig(t *testing.T) { }, wantErr: "", }, + { + name: "valid delimiter with 3 characters", + config: &CSVConfig{ + Quote: "\"", + Delimiter: "|@|", + BinaryEncodingMethod: BinaryEncodingHex, + }, + wantErr: "", + }, { name: "delimiter is empty", config: &CSVConfig{ @@ -359,12 +368,12 @@ func TestValidateAndAdjustCSVConfig(t *testing.T) { wantErr: "csv config delimiter contains line break characters", }, { - name: "delimiter contains more than two characters", + name: "delimiter contains more than three characters", config: &CSVConfig{ Quote: "'", - Delimiter: "FEF", + Delimiter: "FEFA", }, - wantErr: "csv config delimiter contains more than two character, note that escape " + + wantErr: "csv config delimiter contains more than three characters, note that escape " + "sequences can only be used in double quotes in toml configuration items.", }, {