morningman commented on code in PR #50379:
URL: https://github.com/apache/doris/pull/50379#discussion_r2077071064


##########
be/src/vec/exec/format/csv/csv_reader.cpp:
##########
@@ -395,14 +328,10 @@ Status CsvReader::init_reader(bool is_load) {
     if (_enclose == 0) {
         text_line_reader_ctx = std::make_shared<PlainTextLineReaderCtx>(

Review Comment:
   How about unify the naming of `PlainTextLineReaderCtx` and 
`EncloseCsvLineReaderContext`?
   eg:
   - PlainCsvLineReaderCtx
   - EncloseCsvLineReaderCtx



##########
be/src/vec/data_types/serde/data_type_string_serde.h:
##########
@@ -64,6 +64,31 @@ inline void escape_string(const char* src, size_t& len, char 
escape_char) {
     len = dest_ptr - start;
 }
 
+// specially escape quote with double quote
+inline void escape_string_for_csv(const char* src, size_t& len, char 
escape_char, char quote_char) {

Review Comment:
   better use pointer for out parameter



##########
be/src/vec/exec/format/csv/csv_reader.cpp:
##########
@@ -395,14 +328,10 @@ Status CsvReader::init_reader(bool is_load) {
     if (_enclose == 0) {
         text_line_reader_ctx = std::make_shared<PlainTextLineReaderCtx>(
                 _line_delimiter, _line_delimiter_length, _keep_cr);
-        if (_text_serde_type == TTextSerdeType::HIVE_TEXT_SERDE) {
-            _fields_splitter = std::make_unique<HiveCsvTextFieldSplitter>(
-                    _trim_tailing_spaces, false, _value_separator, 
_value_separator_length, -1,
-                    _escape);
-        } else {
-            _fields_splitter = std::make_unique<PlainCsvTextFieldSplitter>(
-                    _trim_tailing_spaces, false, _value_separator, 
_value_separator_length, -1);
-        }
+        // TODO: make sure what table this splitter is used for

Review Comment:
   What is this TODO mean?



##########
be/src/vec/exec/format/csv/csv_reader.cpp:
##########
@@ -649,11 +577,10 @@ Status CsvReader::_fill_dest_columns(const Slice& line, 
Block* block,
 
     for (int i = 0; i < _file_slot_descs.size(); ++i) {
         int col_idx = _col_idxs[i];
-        // col idx is out of range, fill with null.
-        const Slice& value = col_idx < _split_values.size()
-                                     ? _split_values[col_idx]
-                                     : Slice {_options.null_format, 
_options.null_len};
-        Slice slice {value.data, value.size};
+        // col idx is out of range, fill with null format
+        auto value = col_idx < _split_values.size()
+                             ? _split_values[col_idx]
+                             : Slice(_options.null_format, _options.null_len);

Review Comment:
   the `_options.null_len` may be zero?
   And as you said, there is no definition for `null` value in csv, so how do 
we define `null` here?



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/LoadScanProvider.java:
##########
@@ -97,7 +96,8 @@ public FileLoadScanNode.ParamCreateContext 
createContext(Analyzer analyzer) thro
         }
         if (fileGroupInfo.getFileGroup().getFileFormat() != null
                 && 
fileGroupInfo.getFileGroup().getFileFormat().equals("hive_text")) {
-            params.setTextSerdeType(TTextSerdeType.HIVE_TEXT_SERDE);
+            // TODO: set correct format type for load job

Review Comment:
   How to resolve this TODO?



##########
be/src/vec/exec/format/text/text_reader.cpp:
##########
@@ -0,0 +1,466 @@
+// 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.
+
+#include "text_reader.h"
+
+#include <gen_cpp/PlanNodes_types.h>
+#include <gen_cpp/Types_types.h>
+#include <glog/logging.h>
+
+#include "common/compiler_util.h" // IWYU pragma: keep
+#include "common/status.h"
+#include "exec/decompressor.h"
+#include "exec/line_reader.h"
+#include "io/file_factory.h"
+#include "io/fs/buffered_reader.h"
+#include "io/fs/file_reader.h"
+#include "io/fs/s3_file_reader.h"
+#include "runtime/descriptors.h"
+#include "runtime/runtime_state.h"
+#include "vec/core/block.h"
+#include "vec/core/column_with_type_and_name.h"
+#include "vec/data_types/data_type_factory.hpp"
+#include "vec/exec/format/file_reader/new_plain_text_line_reader.h"
+#include "vec/exec/scan/scanner.h"
+
+namespace doris::vectorized {
+#include "common/compile_check_begin.h"
+
+void HiveCsvTextFieldSplitter::do_split(const Slice& line, std::vector<Slice>* 
splitted_values) {

Review Comment:
   ```suggestion
   void HiveTextFieldSplitter::do_split(const Slice& line, std::vector<Slice>* 
splitted_values) {
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to