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 2022/10/20 08:10:07 UTC

[GitHub] [doris] morningman opened a new pull request, #13515: [fix](csv-reader) fix bug that csv reader can not read text format hms table

morningman opened a new pull request, #13515:
URL: https://github.com/apache/doris/pull/13515

   # Proposed changes
   
   Issue Number: close #xxx
   
   ## Problem summary
   
   1. Missing field and line delimiter
   2. When query external table with text(csv) format, we should pass the column position map to BE,
       otherwise the column order is wrong.
   
   TODO:
   1. For now, if we query csv file with non-exist column, it will return null.
       But it should return null or default value of that column.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: 
       - [ ] Yes
       - [ ] No
       - [ ] I don't know
   4. Has unit tests been added:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   5. Has document been added or modified:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   6. Does it need to update dependencies:
       - [ ] Yes
       - [ ] No
   7. Are there any changes that cannot be rolled back:
       - [ ] Yes (If Yes, please explain WHY)
       - [ ] No
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto: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] [doris] morningman commented on a diff in pull request #13515: [fix](csv-reader) fix bug that csv reader can not read text format hms table

Posted by GitBox <gi...@apache.org>.
morningman commented on code in PR #13515:
URL: https://github.com/apache/doris/pull/13515#discussion_r1001294789


##########
be/src/vec/exec/format/csv/csv_reader.cpp:
##########
@@ -134,10 +150,19 @@ Status CsvReader::get_next_block(Block* block, size_t* read_rows, bool* eof) {
         return Status::OK();
     }
 
-    const int batch_size = _state->batch_size();
-    auto columns = block->mutate_columns();
+    if (!_init_column_pos) {
+        // Save mapping from file slot desc to column in block, so that we don't need to
+        // find column in block by name every time.
+        for (int i = 0; i < _file_slot_descs.size(); ++i) {
+            size_t position = block->get_position_by_name(_file_slot_descs[i]->col_name());
+            _col_posistions.push_back(position);
+        }
+        _init_column_pos = true;
+    }

Review Comment:
   removed



-- 
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] [doris] BePPPower commented on a diff in pull request #13515: [fix](csv-reader) fix bug that csv reader can not read text format hms table

Posted by GitBox <gi...@apache.org>.
BePPPower commented on code in PR #13515:
URL: https://github.com/apache/doris/pull/13515#discussion_r1000849750


##########
be/src/vec/exec/format/csv/csv_reader.cpp:
##########
@@ -134,10 +150,19 @@ Status CsvReader::get_next_block(Block* block, size_t* read_rows, bool* eof) {
         return Status::OK();
     }
 
-    const int batch_size = _state->batch_size();
-    auto columns = block->mutate_columns();
+    if (!_init_column_pos) {
+        // Save mapping from file slot desc to column in block, so that we don't need to
+        // find column in block by name every time.
+        for (int i = 0; i < _file_slot_descs.size(); ++i) {
+            size_t position = block->get_position_by_name(_file_slot_descs[i]->col_name());
+            _col_posistions.push_back(position);
+        }
+        _init_column_pos = true;
+    }

Review Comment:
   Isn't `_file_slot_descs[i]` and `block->get_by_position(i)` corresponding?



-- 
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] [doris] morningman merged pull request #13515: [fix](csv-reader) fix bug that csv reader can not read text format hms table

Posted by GitBox <gi...@apache.org>.
morningman merged PR #13515:
URL: https://github.com/apache/doris/pull/13515


-- 
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] [doris] hello-stephen commented on pull request #13515: [fix](csv-reader) fix bug that csv reader can not read text format hms table

Posted by GitBox <gi...@apache.org>.
hello-stephen commented on PR #13515:
URL: https://github.com/apache/doris/pull/13515#issuecomment-1285827353

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 41.29 seconds
    load time: 560 seconds
    storage size: 17154602812 Bytes
    https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20221020161852_clickbench_pr_32097.html


-- 
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] [doris] BePPPower commented on a diff in pull request #13515: [fix](csv-reader) fix bug that csv reader can not read text format hms table

Posted by GitBox <gi...@apache.org>.
BePPPower commented on code in PR #13515:
URL: https://github.com/apache/doris/pull/13515#discussion_r1000829421


##########
be/src/vec/exec/format/csv/csv_reader.cpp:
##########
@@ -150,16 +175,15 @@ Status CsvReader::get_next_block(Block* block, size_t* read_rows, bool* eof) {
             continue;
         }
 
-        // TODO(ftw): check read_rows?
-        ++(*read_rows);
-        RETURN_IF_ERROR(_fill_dest_columns(Slice(ptr, size), columns));
+        RETURN_IF_ERROR(_fill_dest_columns(Slice(ptr, size), block));
+        ++rows;
 
         if (_line_reader_eof == true) {
             *eof = true;
             break;
         }

Review Comment:
   I think this judgment is redundant and it is wasting time if we judge it every time in the `while` loop.
   ```suggestion
   ```



##########
be/src/vec/exec/format/csv/csv_reader.cpp:
##########
@@ -134,10 +150,19 @@ Status CsvReader::get_next_block(Block* block, size_t* read_rows, bool* eof) {
         return Status::OK();
     }
 
-    const int batch_size = _state->batch_size();
-    auto columns = block->mutate_columns();
+    if (!_init_column_pos) {
+        // Save mapping from file slot desc to column in block, so that we don't need to
+        // find column in block by name every time.
+        for (int i = 0; i < _file_slot_descs.size(); ++i) {
+            size_t position = block->get_position_by_name(_file_slot_descs[i]->col_name());
+            _col_posistions.push_back(position);
+        }
+        _init_column_pos = true;
+    }
 
-    while (columns[0]->size() < batch_size && !_line_reader_eof) {
+    const int batch_size = _state->batch_size();
+    int rows = 0;
+    while (rows < batch_size && !_line_reader_eof) {

Review Comment:
   `_fill_dest_columns` may filter invalid line and `block` does not actually add a new line. But `++rows` may make the `while(row < bactch_size)` exit in advance.



-- 
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] [doris] BePPPower commented on a diff in pull request #13515: [fix](csv-reader) fix bug that csv reader can not read text format hms table

Posted by GitBox <gi...@apache.org>.
BePPPower commented on code in PR #13515:
URL: https://github.com/apache/doris/pull/13515#discussion_r1000839204


##########
be/src/vec/exec/format/csv/csv_reader.h:
##########
@@ -57,6 +58,16 @@ class CsvReader : public GenericReader {
     const TFileScanRangeParams& _params;
     const TFileRangeDesc& _range;
     const std::vector<SlotDescriptor*>& _file_slot_descs;
+    // Only for query task, save the columns' index which need to be read.
+    // eg, there are 3 cols in "_file_slot_descs" named: k1, k2, k3
+    // and the corressponding pposition in file is 0, 3, 5.

Review Comment:
   ```suggestion
       // and the corressponding position in file is 0, 3, 5.
   ```



-- 
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] [doris] morningman commented on a diff in pull request #13515: [fix](csv-reader) fix bug that csv reader can not read text format hms table

Posted by GitBox <gi...@apache.org>.
morningman commented on code in PR #13515:
URL: https://github.com/apache/doris/pull/13515#discussion_r1001294662


##########
be/src/vec/exec/format/csv/csv_reader.cpp:
##########
@@ -150,16 +175,15 @@ Status CsvReader::get_next_block(Block* block, size_t* read_rows, bool* eof) {
             continue;
         }
 
-        // TODO(ftw): check read_rows?
-        ++(*read_rows);
-        RETURN_IF_ERROR(_fill_dest_columns(Slice(ptr, size), columns));
+        RETURN_IF_ERROR(_fill_dest_columns(Slice(ptr, size), block));
+        ++rows;
 
         if (_line_reader_eof == true) {
             *eof = true;
             break;
         }

Review Comment:
   removed



##########
be/src/vec/exec/format/csv/csv_reader.cpp:
##########
@@ -134,10 +150,19 @@ Status CsvReader::get_next_block(Block* block, size_t* read_rows, bool* eof) {
         return Status::OK();
     }
 
-    const int batch_size = _state->batch_size();
-    auto columns = block->mutate_columns();
+    if (!_init_column_pos) {
+        // Save mapping from file slot desc to column in block, so that we don't need to
+        // find column in block by name every time.
+        for (int i = 0; i < _file_slot_descs.size(); ++i) {
+            size_t position = block->get_position_by_name(_file_slot_descs[i]->col_name());
+            _col_posistions.push_back(position);
+        }
+        _init_column_pos = true;
+    }
 
-    while (columns[0]->size() < batch_size && !_line_reader_eof) {
+    const int batch_size = _state->batch_size();
+    int rows = 0;
+    while (rows < batch_size && !_line_reader_eof) {

Review Comment:
   fixed



-- 
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] [doris] hello-stephen commented on pull request #13515: [fix](csv-reader) fix bug that csv reader can not read text format hms table

Posted by GitBox <gi...@apache.org>.
hello-stephen commented on PR #13515:
URL: https://github.com/apache/doris/pull/13515#issuecomment-1286425103

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 41.81 seconds
    load time: 629 seconds
    storage size: 17154816178 Bytes
    https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20221021035603_clickbench_pr_32306.html


-- 
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