You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2021/08/04 05:54:37 UTC

[GitHub] [incubator-doris] wunan1210 opened a new pull request #6373: doriswriter support csv

wunan1210 opened a new pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373


   ## Proposed changes
   
   make doriswriter of DataX support format csv.  Format csv is more simple and faster than format json when data is simple(maybe, i think ...).
   
   add property format: csv/json
   add property column_separator: effect when format is csv, for example "\x01" , "^", etc...
   
   ## Types of changes
   
   What types of changes does your code introduce to Doris?
   _Put an `x` in the boxes that apply_
   
   - [ ] Bugfix (non-breaking change which fixes an issue)
   - [x] New feature (non-breaking change which adds functionality)
   - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
   - [ ] Documentation Update (if none of the other choices apply)
   - [ ] Code refactor (Modify the code structure, format the code, etc...)
   - [ ] Optimization. Including functional usability improvements and performance improvements.
   - [ ] Dependency. Such as changes related to third-party components.
   - [ ] Other.
   
   ## Checklist
   
   _Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._
   
   - [ ] I have created an issue on (Fix #ISSUE) and described the bug/feature there in detail
   - [x] Compiling and unit tests pass locally with my changes
   - [ ] I have added tests that prove my fix is effective or that my feature works
   - [ ] If these changes need document changes, I have updated the document
   - [ ] Any dependent changes have been merged
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] morningman commented on pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
morningman commented on pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#issuecomment-892716785


   > I don't think there's any need to do a conversion here, and the csv format can cause problems, such as empty strings, with the separator you specify in the data,The json format is the least error-prone
   
   I think it ok to offer a option to user. And the default column separator can be multi-bytes separator to avoid some problems


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] hf200012 commented on pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
hf200012 commented on pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#issuecomment-892621966


   I don't think there's any need to do a conversion here, and the csv format can cause problems, such as empty strings, with the separator you specify in the data,The json format is the least error-prone


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] morningman commented on a change in pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
morningman commented on a change in pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#discussion_r682664777



##########
File path: extension/DataX/doriswriter/src/main/java/com/alibaba/datax/plugin/writer/doriswriter/DorisCsvCodec.java
##########
@@ -0,0 +1,53 @@
+/*
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+ */
+package com.alibaba.datax.plugin.writer.doriswriter;
+
+import com.alibaba.datax.common.element.Record;
+import com.alibaba.fastjson.JSON;
+
+import java.util.*;
+
+// Convert DataX data to csv
+public class DorisCsvCodec extends DorisCodec {
+    private static TimeZone timeZoner = TimeZone.getTimeZone(timeZone);
+
+    private String columnSeparator;
+
+    public DorisCsvCodec(final List<String> fieldNames, String columnSeparator) {
+        super(fieldNames);
+        this.columnSeparator = columnSeparator;
+    }
+
+    @Override
+    public String serialize(final Record row) {
+        if (null == this.fieldNames) {
+            return "";
+        }
+        List<String> list = new ArrayList<>();
+
+        for (int i = 0; i < this.fieldNames.size(); i++) {
+            Object value = this.convertColumn(row.getColumn(i));
+            list.add(value != null ? value.toString() : "");

Review comment:
       for null value, it should be `"\N"`

##########
File path: extension/DataX/doriswriter/src/main/java/com/alibaba/datax/plugin/writer/doriswriter/Key.java
##########
@@ -22,6 +22,8 @@ Licensed to the Apache Software Foundation (ASF) under one
 import com.alibaba.datax.common.exception.DataXException;
 import com.alibaba.datax.common.util.Configuration;
 import com.alibaba.datax.plugin.rdbms.util.DBUtilErrorCode;
+import com.alibaba.fastjson.JSON;

Review comment:
       unused imports?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] morningman commented on pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
morningman commented on pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#issuecomment-892716785






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] wunan1210 edited a comment on pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
wunan1210 edited a comment on pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#issuecomment-893085765


   When in stream load using format csv, does Doris recognize string '' or null ?
   My tests show only insert '' .
   Can Doris insert null in this way ? Maybe a limitation when using format csv ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] morningman merged pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
morningman merged pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] wunan1210 commented on pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
wunan1210 commented on pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#issuecomment-893085765






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] github-actions[bot] commented on pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#issuecomment-894756427






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] morningman commented on pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
morningman commented on pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#issuecomment-893097860


   > When in stream load using format csv, does Doris recognize string '' or null ?
   > My tests show only insert '' .
   > Can Doris insert null in this way ? Maybe a limitation when using format csv ?
   
   For null value, it should be "\N"


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] wunan1210 commented on a change in pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
wunan1210 commented on a change in pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#discussion_r683044888



##########
File path: extension/DataX/doriswriter/doc/doriswriter.md
##########
@@ -163,6 +163,18 @@ DorisWriter 通过Doris原生支持Stream load方式导入数据, DorisWriter
   - 描述:每批次数据包含多行,每行为 Json 格式,每行的的分隔符即为 lineDelimiter。
   - 必选:否
   - 默认值:`\n`
+  
+* **format**
+
+  - 描述:导入数据的格式, 可以使是json或者csv。
+  - 必选:否
+  - 默认值:`json`
+  
+* **columnSeparator**
+
+  - 描述:当导入的格式是csv时, 字段之间的分隔符。
+  - 必选:否
+  - 默认值:`\t`

Review comment:
       already support invisible multi-bytes, like '\x01\x02'. but in version 0.14,  doris seem to only accept one byte. Branch master looks to handle multi-bytes .  ^_^




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] hf200012 commented on pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
hf200012 commented on pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#issuecomment-892621966


   I don't think there's any need to do a conversion here, and the csv format can cause problems, such as empty strings, with the separator you specify in the data,The json format is the least error-prone


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] morningman commented on a change in pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
morningman commented on a change in pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#discussion_r683067136



##########
File path: extension/DataX/doriswriter/src/main/java/com/alibaba/datax/plugin/writer/doriswriter/DorisCsvCodec.java
##########
@@ -0,0 +1,53 @@
+/*
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+ */
+package com.alibaba.datax.plugin.writer.doriswriter;
+
+import com.alibaba.datax.common.element.Record;
+import com.alibaba.fastjson.JSON;
+
+import java.util.*;
+
+// Convert DataX data to csv
+public class DorisCsvCodec extends DorisCodec {
+    private static TimeZone timeZoner = TimeZone.getTimeZone(timeZone);
+
+    private String columnSeparator;
+
+    public DorisCsvCodec(final List<String> fieldNames, String columnSeparator) {
+        super(fieldNames);
+        this.columnSeparator = columnSeparator;
+    }
+
+    @Override
+    public String serialize(final Record row) {
+        if (null == this.fieldNames) {
+            return "";
+        }
+        List<String> list = new ArrayList<>();
+
+        for (int i = 0; i < this.fieldNames.size(); i++) {
+            Object value = this.convertColumn(row.getColumn(i));
+            list.add(value != null ? value.toString() : "");

Review comment:
       Like this: `list.add(value != null ? value.toString() : "\\N");`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] wunan1210 commented on pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
wunan1210 commented on pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#issuecomment-893184888


   > > When in stream load using format csv, does Doris recognize string '' or null ?
   > > My tests show only insert '' .
   > > Can Doris insert null in this way ? Maybe a limitation when using format csv ?
   > 
   > For null value, it should be "\N"
   
   thanks for your comment, it confused me a lot ╰( ̄▽ ̄)╮


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] morningman commented on a change in pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
morningman commented on a change in pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#discussion_r682664777



##########
File path: extension/DataX/doriswriter/src/main/java/com/alibaba/datax/plugin/writer/doriswriter/DorisCsvCodec.java
##########
@@ -0,0 +1,53 @@
+/*
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+ */
+package com.alibaba.datax.plugin.writer.doriswriter;
+
+import com.alibaba.datax.common.element.Record;
+import com.alibaba.fastjson.JSON;
+
+import java.util.*;
+
+// Convert DataX data to csv
+public class DorisCsvCodec extends DorisCodec {
+    private static TimeZone timeZoner = TimeZone.getTimeZone(timeZone);
+
+    private String columnSeparator;
+
+    public DorisCsvCodec(final List<String> fieldNames, String columnSeparator) {
+        super(fieldNames);
+        this.columnSeparator = columnSeparator;
+    }
+
+    @Override
+    public String serialize(final Record row) {
+        if (null == this.fieldNames) {
+            return "";
+        }
+        List<String> list = new ArrayList<>();
+
+        for (int i = 0; i < this.fieldNames.size(); i++) {
+            Object value = this.convertColumn(row.getColumn(i));
+            list.add(value != null ? value.toString() : "");

Review comment:
       for null value, it should be `"\N"`

##########
File path: extension/DataX/doriswriter/src/main/java/com/alibaba/datax/plugin/writer/doriswriter/Key.java
##########
@@ -22,6 +22,8 @@ Licensed to the Apache Software Foundation (ASF) under one
 import com.alibaba.datax.common.exception.DataXException;
 import com.alibaba.datax.common.util.Configuration;
 import com.alibaba.datax.plugin.rdbms.util.DBUtilErrorCode;
+import com.alibaba.fastjson.JSON;

Review comment:
       unused imports?

##########
File path: extension/DataX/doriswriter/doc/doriswriter.md
##########
@@ -163,6 +163,18 @@ DorisWriter 通过Doris原生支持Stream load方式导入数据, DorisWriter
   - 描述:每批次数据包含多行,每行为 Json 格式,每行的的分隔符即为 lineDelimiter。
   - 必选:否
   - 默认值:`\n`
+  
+* **format**
+
+  - 描述:导入数据的格式, 可以使是json或者csv。
+  - 必选:否
+  - 默认值:`json`
+  
+* **columnSeparator**
+
+  - 描述:当导入的格式是csv时, 字段之间的分隔符。
+  - 必选:否
+  - 默认值:`\t`

Review comment:
       There may be any character exist in user data, such as `\t` or `,`.
   So it is better to use a invisible multi-bytes separator as default column separator here, I recommend to use `\x0707`

##########
File path: extension/DataX/doriswriter/src/main/java/com/alibaba/datax/plugin/writer/doriswriter/DorisCsvCodec.java
##########
@@ -0,0 +1,53 @@
+/*
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+ */
+package com.alibaba.datax.plugin.writer.doriswriter;
+
+import com.alibaba.datax.common.element.Record;
+import com.alibaba.fastjson.JSON;
+
+import java.util.*;
+
+// Convert DataX data to csv
+public class DorisCsvCodec extends DorisCodec {
+    private static TimeZone timeZoner = TimeZone.getTimeZone(timeZone);
+
+    private String columnSeparator;
+
+    public DorisCsvCodec(final List<String> fieldNames, String columnSeparator) {
+        super(fieldNames);
+        this.columnSeparator = columnSeparator;
+    }
+
+    @Override
+    public String serialize(final Record row) {
+        if (null == this.fieldNames) {
+            return "";
+        }
+        List<String> list = new ArrayList<>();
+
+        for (int i = 0; i < this.fieldNames.size(); i++) {
+            Object value = this.convertColumn(row.getColumn(i));
+            list.add(value != null ? value.toString() : "");

Review comment:
       Like this: `list.add(value != null ? value.toString() : "\\N");`

##########
File path: extension/DataX/doriswriter/doc/doriswriter.md
##########
@@ -163,6 +163,18 @@ DorisWriter 通过Doris原生支持Stream load方式导入数据, DorisWriter
   - 描述:每批次数据包含多行,每行为 Json 格式,每行的的分隔符即为 lineDelimiter。
   - 必选:否
   - 默认值:`\n`
+  
+* **format**
+
+  - 描述:导入数据的格式, 可以使是json或者csv。
+  - 必选:否
+  - 默认值:`json`
+  
+* **columnSeparator**
+
+  - 描述:当导入的格式是csv时, 字段之间的分隔符。
+  - 必选:否
+  - 默认值:`\t`

Review comment:
       OK I see. So please modify the description to remind this risk.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] wunan1210 commented on a change in pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
wunan1210 commented on a change in pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#discussion_r683049093



##########
File path: extension/DataX/doriswriter/src/main/java/com/alibaba/datax/plugin/writer/doriswriter/Key.java
##########
@@ -22,6 +22,8 @@ Licensed to the Apache Software Foundation (ASF) under one
 import com.alibaba.datax.common.exception.DataXException;
 import com.alibaba.datax.common.util.Configuration;
 import com.alibaba.datax.plugin.rdbms.util.DBUtilErrorCode;
+import com.alibaba.fastjson.JSON;

Review comment:
       my carelessness ...




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] wunan1210 commented on pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
wunan1210 commented on pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#issuecomment-893085765


   When in stream load using format csv, does Doris recognize string '' ornull ?
   My tests show only insert '' .
   Can Doris insert null in this way ? Maybe a limitation when using format csv ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] wunan1210 commented on a change in pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
wunan1210 commented on a change in pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#discussion_r683050594



##########
File path: extension/DataX/doriswriter/doc/doriswriter.md
##########
@@ -163,6 +163,18 @@ DorisWriter 通过Doris原生支持Stream load方式导入数据, DorisWriter
   - 描述:每批次数据包含多行,每行为 Json 格式,每行的的分隔符即为 lineDelimiter。
   - 必选:否
   - 默认值:`\n`
+  
+* **format**
+
+  - 描述:导入数据的格式, 可以使是json或者csv。
+  - 必选:否
+  - 默认值:`json`
+  
+* **columnSeparator**
+
+  - 描述:当导入的格式是csv时, 字段之间的分隔符。
+  - 必选:否
+  - 默认值:`\t`

Review comment:
       You mean like this ?
   ```
   list.add((value == null || value.equals("\\N")) ? "" : value.toString());
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] wunan1210 edited a comment on pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
wunan1210 edited a comment on pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#issuecomment-893085765


   When in stream load using format csv, does Doris recognize string '' or null ?
   My tests show only insert '' .
   Can Doris insert null in this way ? Maybe a limitation when using format csv ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] wunan1210 commented on a change in pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
wunan1210 commented on a change in pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#discussion_r683050854



##########
File path: extension/DataX/doriswriter/src/main/java/com/alibaba/datax/plugin/writer/doriswriter/DorisCsvCodec.java
##########
@@ -0,0 +1,53 @@
+/*
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+ */
+package com.alibaba.datax.plugin.writer.doriswriter;
+
+import com.alibaba.datax.common.element.Record;
+import com.alibaba.fastjson.JSON;
+
+import java.util.*;
+
+// Convert DataX data to csv
+public class DorisCsvCodec extends DorisCodec {
+    private static TimeZone timeZoner = TimeZone.getTimeZone(timeZone);
+
+    private String columnSeparator;
+
+    public DorisCsvCodec(final List<String> fieldNames, String columnSeparator) {
+        super(fieldNames);
+        this.columnSeparator = columnSeparator;
+    }
+
+    @Override
+    public String serialize(final Record row) {
+        if (null == this.fieldNames) {
+            return "";
+        }
+        List<String> list = new ArrayList<>();
+
+        for (int i = 0; i < this.fieldNames.size(); i++) {
+            Object value = this.convertColumn(row.getColumn(i));
+            list.add(value != null ? value.toString() : "");

Review comment:
       You mean like this ?
   ```
   list.add((value == null || value.equals("\\N")) ? "" : value.toString());
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] wunan1210 commented on a change in pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
wunan1210 commented on a change in pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#discussion_r683044888



##########
File path: extension/DataX/doriswriter/doc/doriswriter.md
##########
@@ -163,6 +163,18 @@ DorisWriter 通过Doris原生支持Stream load方式导入数据, DorisWriter
   - 描述:每批次数据包含多行,每行为 Json 格式,每行的的分隔符即为 lineDelimiter。
   - 必选:否
   - 默认值:`\n`
+  
+* **format**
+
+  - 描述:导入数据的格式, 可以使是json或者csv。
+  - 必选:否
+  - 默认值:`json`
+  
+* **columnSeparator**
+
+  - 描述:当导入的格式是csv时, 字段之间的分隔符。
+  - 必选:否
+  - 默认值:`\t`

Review comment:
       already support invisible multi-bytes, like '\x01\x02'. but in version 0.14,  doris seem to only accept one byte. Branch master looks to handle multi-bytes .  ^_^

##########
File path: extension/DataX/doriswriter/src/main/java/com/alibaba/datax/plugin/writer/doriswriter/Key.java
##########
@@ -22,6 +22,8 @@ Licensed to the Apache Software Foundation (ASF) under one
 import com.alibaba.datax.common.exception.DataXException;
 import com.alibaba.datax.common.util.Configuration;
 import com.alibaba.datax.plugin.rdbms.util.DBUtilErrorCode;
+import com.alibaba.fastjson.JSON;

Review comment:
       my carelessness ...

##########
File path: extension/DataX/doriswriter/doc/doriswriter.md
##########
@@ -163,6 +163,18 @@ DorisWriter 通过Doris原生支持Stream load方式导入数据, DorisWriter
   - 描述:每批次数据包含多行,每行为 Json 格式,每行的的分隔符即为 lineDelimiter。
   - 必选:否
   - 默认值:`\n`
+  
+* **format**
+
+  - 描述:导入数据的格式, 可以使是json或者csv。
+  - 必选:否
+  - 默认值:`json`
+  
+* **columnSeparator**
+
+  - 描述:当导入的格式是csv时, 字段之间的分隔符。
+  - 必选:否
+  - 默认值:`\t`

Review comment:
       You mean like this ?
   ```
   list.add((value == null || value.equals("\\N")) ? "" : value.toString());
   ```

##########
File path: extension/DataX/doriswriter/src/main/java/com/alibaba/datax/plugin/writer/doriswriter/DorisCsvCodec.java
##########
@@ -0,0 +1,53 @@
+/*
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+ */
+package com.alibaba.datax.plugin.writer.doriswriter;
+
+import com.alibaba.datax.common.element.Record;
+import com.alibaba.fastjson.JSON;
+
+import java.util.*;
+
+// Convert DataX data to csv
+public class DorisCsvCodec extends DorisCodec {
+    private static TimeZone timeZoner = TimeZone.getTimeZone(timeZone);
+
+    private String columnSeparator;
+
+    public DorisCsvCodec(final List<String> fieldNames, String columnSeparator) {
+        super(fieldNames);
+        this.columnSeparator = columnSeparator;
+    }
+
+    @Override
+    public String serialize(final Record row) {
+        if (null == this.fieldNames) {
+            return "";
+        }
+        List<String> list = new ArrayList<>();
+
+        for (int i = 0; i < this.fieldNames.size(); i++) {
+            Object value = this.convertColumn(row.getColumn(i));
+            list.add(value != null ? value.toString() : "");

Review comment:
       You mean like this ?
   ```
   list.add((value == null || value.equals("\\N")) ? "" : value.toString());
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] morningman commented on a change in pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
morningman commented on a change in pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#discussion_r682681729



##########
File path: extension/DataX/doriswriter/doc/doriswriter.md
##########
@@ -163,6 +163,18 @@ DorisWriter 通过Doris原生支持Stream load方式导入数据, DorisWriter
   - 描述:每批次数据包含多行,每行为 Json 格式,每行的的分隔符即为 lineDelimiter。
   - 必选:否
   - 默认值:`\n`
+  
+* **format**
+
+  - 描述:导入数据的格式, 可以使是json或者csv。
+  - 必选:否
+  - 默认值:`json`
+  
+* **columnSeparator**
+
+  - 描述:当导入的格式是csv时, 字段之间的分隔符。
+  - 必选:否
+  - 默认值:`\t`

Review comment:
       There may be any character exist in user data, such as `\t` or `,`.
   So it is better to use a invisible multi-bytes separator as default column separator here, I recommend to use `\x0707`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] morningman commented on a change in pull request #6373: doriswriter support csv

Posted by GitBox <gi...@apache.org>.
morningman commented on a change in pull request #6373:
URL: https://github.com/apache/incubator-doris/pull/6373#discussion_r683068038



##########
File path: extension/DataX/doriswriter/doc/doriswriter.md
##########
@@ -163,6 +163,18 @@ DorisWriter 通过Doris原生支持Stream load方式导入数据, DorisWriter
   - 描述:每批次数据包含多行,每行为 Json 格式,每行的的分隔符即为 lineDelimiter。
   - 必选:否
   - 默认值:`\n`
+  
+* **format**
+
+  - 描述:导入数据的格式, 可以使是json或者csv。
+  - 必选:否
+  - 默认值:`json`
+  
+* **columnSeparator**
+
+  - 描述:当导入的格式是csv时, 字段之间的分隔符。
+  - 必选:否
+  - 默认值:`\t`

Review comment:
       OK I see. So please modify the description to remind this risk.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org