Registry Mirror
Skip to content

doris-flink-connecter数据换行配置不起作用 #6550

Closed

Description

@yangmingjie

Search before asking

  • I had searched in the issues and found no similar issues.

Version

1.0.0

What's Wrong?

在使用doris-connector的时候,数据导入到doris一部分的试试报错:
image

最后发现问题如下:

mysql数据库中有个字段mateName是varchar(255),如下:
image
拷贝出来后内容,有换行:
image

然后,

image

但是 还是报一次样的错误。

What You Expected?

希望设置换行符 sink.properties.line_delimiter 和 sink.properties.column_separator 能起作用。或者其他解决这个问题的办法。

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. added
    kind/fix
    on Sep 2, 2021
  2. JNSimba commented on Sep 2, 2021

    @JNSimba
    Member
  3. minchowang commented on Sep 13, 2021

    @minchowang

    @JNSimba Has this problem been solved?

  4. JNSimba commented on Sep 13, 2021

    @JNSimba
    Member

    @JNSimba Has this problem been solved?

    Specify the newline character to set the
    sink.properties.line_delimiter parameters

  5. minchowang commented on Sep 14, 2021

    @minchowang

    @JNSimba thanks for your reply. here is my code, and some errors.
    doris ddl:

    CREATE TABLE `product` (
      `id` int(11) NULL COMMENT "",
    ...
      `gmt_modified` datetime NULL COMMENT "",
      `gmt_create` datetime NULL COMMENT ""
    ) ENGINE=OLAP
    DUPLICATE KEY(`id`, `id_hash`)
    COMMENT "OLAP"
    DISTRIBUTED BY HASH(`id`) BUCKETS 10
    PROPERTIES (
    "replication_num" = "3",
    "in_memory" = "false",
    "storage_format" = "V2"
    );
    

    flink sql doris-sink ddl:

    CREATE TABLE product (
     id INT,
    ...
     gmt_modified TIMESTAMP(6),
     gmt_create TIMESTAMP(6) ) 
    WITH (  
     'connector' = 'doris', 
     'fenodes' = 'n3:8031', 
      'table.identifier' = 'dev.product',  
      'username' = 'root',
      'sink.batch.size' = '100',
      'sink.properties.column_separator' = '\x01',
      'sink.properties.line_delimiter' = '\x02',
      'sink.batch.interval' = '2s' , 
      'password' = 'doris'
    );
    # flink insert sql
    insert into product 
    select * from product_cdc_table ;

    When we write data to dorsi by flink streaming, have following error occurs.
    image

  6. minchowang commented on Sep 14, 2021

    @minchowang

    @JNSimba thanks for your reply. here is my code, and some errors.
    doris ddl:

    CREATE TABLE `product` (
      `id` int(11) NULL COMMENT "",
    ...
      `gmt_modified` datetime NULL COMMENT "",
      `gmt_create` datetime NULL COMMENT ""
    ) ENGINE=OLAP
    DUPLICATE KEY(`id`, `id_hash`)
    COMMENT "OLAP"
    DISTRIBUTED BY HASH(`id`) BUCKETS 10
    PROPERTIES (
    "replication_num" = "3",
    "in_memory" = "false",
    "storage_format" = "V2"
    );

    flink sql doris-sink ddl:

    CREATE TABLE product (
     id INT,
    ...
     gmt_modified TIMESTAMP(6),
     gmt_create TIMESTAMP(6) ) 
    WITH (  
     'connector' = 'doris', 
     'fenodes' = 'n3:8031', 
      'table.identifier' = 'dev.product',  
      'username' = 'root',
      'sink.batch.size' = '100',
      'sink.properties.column_separator' = '\x01',
      'sink.properties.line_delimiter' = '\x02',
      'sink.batch.interval' = '2s' , 
      'password' = 'doris'
    );
    # flink insert sql
    insert into product 
    select * from product_cdc_table ;

    When we write data to dorsi by flink streaming, have following error occurs.
    image

    doris version: 0.14
    flink-doris-connector version : master
    flink version : 1.12.2

    When we repalce column_separator=%x01 and line_delimiter=%x02, have other error occurs :

    Reason: actual column number is more than schema column number. actual number: 1900 sep: %, schema number: 19; . src line: [689%x018a7c7089faaf00c850b90154e74fb821%x01101787%x0111%x010%x010%x010%x01%x01%x01QARFEE 

    We check barch-0.14 and master, look the commit message [Load] Support multi bytes LineDelimiter and ColumnSeparator (#5462) in broker_scanner.cpp, so we are going to verify it.

  7. yangmingjie commented on Sep 15, 2021

    @yangmingjie
    Author

    @JNSimba Has this problem been solved?

    Specify the newline character to set the
    sink.properties.line_delimiter parameters

    我这里试了还是不行,最近一忙就没顾上 @mincwang

  8. JNSimba commented on Sep 15, 2021

    @JNSimba
    Member

    @JNSimba Has this problem been solved?

    Specify the newline character to set the
    sink.properties.line_delimiter parameters

    我这里试了还是不行,最近一忙就没顾上 @mincwang

    @yangmingjie your param line_delimiter(%%%%) and column_separator(%%%%) has the same prefix value, may cause doris to be indistinguishable,modify them to a different prefix and it works

  9. minchowang commented on Sep 15, 2021

    @minchowang

    @JNSimba thanks for your reply. here is my code, and some errors.
    doris ddl:

    CREATE TABLE `product` (
      `id` int(11) NULL COMMENT "",
    ...
      `gmt_modified` datetime NULL COMMENT "",
      `gmt_create` datetime NULL COMMENT ""
    ) ENGINE=OLAP
    DUPLICATE KEY(`id`, `id_hash`)
    COMMENT "OLAP"
    DISTRIBUTED BY HASH(`id`) BUCKETS 10
    PROPERTIES (
    "replication_num" = "3",
    "in_memory" = "false",
    "storage_format" = "V2"
    );

    flink sql doris-sink ddl:

    CREATE TABLE product (
     id INT,
    ...
     gmt_modified TIMESTAMP(6),
     gmt_create TIMESTAMP(6) ) 
    WITH (  
     'connector' = 'doris', 
     'fenodes' = 'n3:8031', 
      'table.identifier' = 'dev.product',  
      'username' = 'root',
      'sink.batch.size' = '100',
      'sink.properties.column_separator' = '\x01',
      'sink.properties.line_delimiter' = '\x02',
      'sink.batch.interval' = '2s' , 
      'password' = 'doris'
    );
    # flink insert sql
    insert into product 
    select * from product_cdc_table ;

    When we write data to dorsi by flink streaming, have following error occurs.
    image

    doris version: 0.14
    flink-doris-connector version : master
    flink version : 1.12.2

    When we repalce column_separator=%x01 and line_delimiter=%x02, have other error occurs :

    Reason: actual column number is more than schema column number. actual number: 1900 sep: %, schema number: 19; . src line: [689%x018a7c7089faaf00c850b90154e74fb821%x01101787%x0111%x010%x010%x010%x01%x01%x01QARFEE 

    We check barch-0.14 and master, look the commit message [Load] Support multi bytes LineDelimiter and ColumnSeparator (#5462) in broker_scanner.cpp, so we are going to verify it.

    @JNSimba Can this PR fix the above problems? please help to confirm.

  10. JNSimba commented on Sep 15, 2021

    @JNSimba
    Member

    @mincwang it is work to change to other characters,hexadecimal may be has problem

  11. minchowang commented on Sep 15, 2021

    @minchowang

    @mincwang it is work to change to other characters,hexadecimal may be has problem

    What do you recommend set for column_separator and line_delimiter ?

  12. JNSimba commented on Sep 16, 2021

    @JNSimba
    Member

    @mincwang it is work to change to other characters,hexadecimal may be has problem

    What do you recommend set for column_separator and line_delimiter ?

    It can be set as a character that does not appear frequently according to the specific business, or it can be set as a combination of multiple characters

  13. minchowang commented on Sep 16, 2021

    @minchowang

    @mincwang it is work to change to other characters,hexadecimal may be has problem

    What do you recommend set for column_separator and line_delimiter ?

    It can be set as a character that does not appear frequently according to the specific business, or it can be set as a combination of multiple characters

    But we doris version is 0.14,only master version support of multiple characters ,fix above problem by this PR #5462.

  14. JNSimba commented on Sep 16, 2021

    @JNSimba
    Member

    @mincwang it is work to change to other characters,hexadecimal may be has problem

    What do you recommend set for column_separator and line_delimiter ?

    It can be set as a character that does not appear frequently according to the specific business, or it can be set as a combination of multiple characters

    But we doris version is 0.14,only master version support of multiple characters ,fix above problem by this PR #5462.

    Sorry, I may not make it clear, I mean it can be specified as multiple letters, like column_separator=doris

  15. yangmingjie commented on Sep 16, 2021

    @yangmingjie
    Author

    @JNSimba Has this problem been solved?

    Specify the newline character to set the
    sink.properties.line_delimiter parameters

    我这里试了还是不行,最近一忙就没顾上 @mincwang

    @yangmingjie your param line_delimiter(%%%%) and column_separator(%%%%) has the same prefix value, may cause doris to be indistinguishable,modify them to a different prefix and it works

    还是不行,是不是我用的不对?
    目标脚本如下:
    企业微信截图_16317736024312
    错误:
    企业微信截图_16317724243359
    另外,换成单个字符,也还是不行,例如:
    'sink.properties.line_delimiter'='#',
    'sink.properties.column_separator'='*'
    也是一样的问题。

  16. yangmingjie commented on Sep 16, 2021

    @yangmingjie
    Author

    我们用的是master分支最新代码打包出来的connector
    doris的版本是 0.14

  17. JNSimba commented on Sep 16, 2021

    @JNSimba
    Member

    @JNSimba Has this problem been solved?

    Specify the newline character to set the
    sink.properties.line_delimiter parameters

    我这里试了还是不行,最近一忙就没顾上 @mincwang

    @yangmingjie your param line_delimiter(%%%%) and column_separator(%%%%) has the same prefix value, may cause doris to be indistinguishable,modify them to a different prefix and it works

    还是不行,是不是我用的不对?
    目标脚本如下:
    企业微信截图_16317736024312
    错误:
    企业微信截图_16317724243359
    另外,换成单个字符,也还是不行,例如:
    'sink.properties.line_delimiter'='#',
    'sink.properties.column_separator'='*'
    也是一样的问题。

    may not the problem of the separator. It is recommended to see if the sql fields are consistent with the fields in the doris table.

  18. minchowang commented on Sep 16, 2021

    @minchowang

    @JNSimba Has this problem been solved?

    Specify the newline character to set the
    sink.properties.line_delimiter parameters

    我这里试了还是不行,最近一忙就没顾上 @mincwang

    @yangmingjie your param line_delimiter(%%%%) and column_separator(%%%%) has the same prefix value, may cause doris to be indistinguishable,modify them to a different prefix and it works

    还是不行,是不是我用的不对?
    目标脚本如下:
    企业微信截图_16317736024312
    错误:
    企业微信截图_16317724243359
    另外,换成单个字符,也还是不行,例如:
    'sink.properties.line_delimiter'='#',
    'sink.properties.column_separator'='*'
    也是一样的问题。

    may not the problem of the separator. It is recommended to see if the sql fields are consistent with the fields in the doris table.

    @JNSimba Can you add a JSON import way? i think will have not these problems.

  19. JNSimba commented on Sep 17, 2021

    @JNSimba
    Member

    @JNSimba Has this problem been solved?

    Specify the newline character to set the
    sink.properties.line_delimiter parameters

    我这里试了还是不行,最近一忙就没顾上 @mincwang

    @yangmingjie your param line_delimiter(%%%%) and column_separator(%%%%) has the same prefix value, may cause doris to be indistinguishable,modify them to a different prefix and it works

    还是不行,是不是我用的不对?
    目标脚本如下:
    企业微信截图_16317736024312
    错误:
    企业微信截图_16317724243359
    另外,换成单个字符,也还是不行,例如:
    'sink.properties.line_delimiter'='#',
    'sink.properties.column_separator'='*'
    也是一样的问题。

    may not the problem of the separator. It is recommended to see if the sql fields are consistent with the fields in the doris table.

    @JNSimba Can you add a JSON import way? i think will have not these problems.

    @mincwang Good idea, will be put on PR as soon as possible

  20. minchowang commented on Sep 17, 2021

    @minchowang

    @JNSimba Has this problem been solved?

    Specify the newline character to set the
    sink.properties.line_delimiter parameters

    我这里试了还是不行,最近一忙就没顾上 @mincwang

    @yangmingjie your param line_delimiter(%%%%) and column_separator(%%%%) has the same prefix value, may cause doris to be indistinguishable,modify them to a different prefix and it works

    还是不行,是不是我用的不对?
    目标脚本如下:
    企业微信截图_16317736024312
    错误:
    企业微信截图_16317724243359
    另外,换成单个字符,也还是不行,例如:
    'sink.properties.line_delimiter'='#',
    'sink.properties.column_separator'='*'
    也是一样的问题。

    may not the problem of the separator. It is recommended to see if the sql fields are consistent with the fields in the doris table.

    @JNSimba Can you add a JSON import way? i think will have not these problems.

    @mincwang Good idea, will be put on PR as soon as possible

    @JNSimba I look forward to your contribution, i hope it can support rowkind convert to a hidden column __DELETE_SIGN__ when use Doris unique model. https://doris.apache.org/master/en/administrator-guide/load-data/batch-delete-manual.html#principle

    RowKind DELETE_SIGN
    +I false
    -U true
    +U false
    -D true
  21. minchowang commented on Sep 17, 2021

    @minchowang

    image

    @JNSimba You can re test my this UT?

    public static void main(String[] args) {
            final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
            env.setParallelism(1);
            final StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);
    
            List<Tuple2<String, Integer>> data = new ArrayList<>();
            data.add(new Tuple2<>("doris", 1));
            data.add(new Tuple2<>("flink", 2));
            DataStreamSource<Tuple2<String, Integer>> source = env.fromCollection(data);
            tEnv.createTemporaryView("doris_test", source, $("name"), $("age"));
    
            tEnv.executeSql(
                    "CREATE TABLE doris_test_sink ("
                            + "name STRING,"
                            + "age INT"
                            + ") "
                            + "WITH (\n"
                            + "  'connector' = 'doris',\n"
                            + "  'fenodes' = 'n3:8031',\n"
                            + "  'table.identifier' = 'erp_dev.student_unique',\n"
                            + "  'sink.properties.column_separator' ='\\t',\n" 
                            + "  'sink.properties.line_delimiter' = '\\n',\n"
                            + "  'username' = 'root',\n"
                            + "  'password' = 'doris'\n"
                            + ")");
    
            tEnv.executeSql("INSERT INTO doris_test_sink select name,age from doris_test");
        }
    

    dorsi be version : 0.14

  22. minchowang commented on Sep 17, 2021

    @minchowang

    My guess this is when DorisStreamLoad#getConnection method body execute conn.addRequestProperty(streamLoadProp),error when carrying these request parameters requesting BE because be 0.14 does not support multi-character delimiters.

    [Load] Support multi bytes LineDelimiter and ColumnSeparator #5462

  23. JNSimba commented on Sep 18, 2021

    @JNSimba
    Member

    My guess this is when DorisStreamLoad#getConnection method body execute conn.addRequestProperty(streamLoadProp),error when carrying these request parameters requesting BE because be 0.14 does not support multi-character delimiters.

    [Load] Support multi bytes LineDelimiter and ColumnSeparator #5462

    @mincwang
    Yes, the above example will fail.
    Since the specified separator is \\t, sink-format uses \\t when splicing data, but when sending a streamload http request, the separator \\t in the request header may be recognized as an escape character \t, The two are not equal, so it cannot be imported.
    And \t 、 \n are the default separators, you don’t need to specify them

  24. JNSimba commented on Sep 18, 2021

    @JNSimba
    Member

    @mincwang Currently the separator is set to \t, HttpURLConnection.checkMessageHeader will report an error: IllegalArgumentException: Illegal character(s) in message header value
    I tried to modify the request to HttpClient to avoid this error, and I will modify it as soon as possible.

  25. minchowang commented on Sep 18, 2021

    @minchowang

    @JNSimba Looking forward to your fix, and how do I check my version of doris?

  26. JNSimba commented on Sep 18, 2021

    @JNSimba
    Member

    @JNSimba Looking forward to your fix, and how do I check my version of doris?

    what mean check the doris version ?

    you can use the default separator, just remove the specify .
    Or use multi-character separation, like column_separator=‘doris’

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions