github-actions[bot] commented on code in PR #62580:
URL: https://github.com/apache/doris/pull/62580#discussion_r3144794316


##########
be/src/format/file_reader/new_plain_text_line_reader.cpp:
##########
@@ -158,6 +158,24 @@ void EncloseCsvLineReaderCtx::_on_pre_match_enclose(const 
uint8_t* start, size_t
             } else if (_quote_escape) {
                 // the last char is quote, so we need to check if the current 
char is quote to determine if it is escaped by quote
                 if (start[_idx] == _enclose) {
+                    // When the column separator starts with the enclose char 
(e.g. enclose=':' and
+                    // sep='::'), the sequence "closing-enclose + separator" 
looks identical to a
+                    // double-quote escape followed by extra chars.  
Disambiguate by peeking ahead:
+                    // if the bytes at the current position match the full 
column separator, the
+                    // previous enclose char was the actual closing enclose 
rather than half of a
+                    // double-quote escape.
+                    if (_sep_starts_with_enclose) {
+                        size_t remaining = len - _idx;
+                        if (remaining >= _column_sep_len &&
+                            memcmp(start + _idx, _column_sep.c_str(), 
_column_sep_len) == 0) {

Review Comment:
   This still breaks when the `closing-enclose + separator` pattern straddles 
two `read_line()` passes on the same logical row. `NewPlainTextLineReader` 
preserves `_idx`, `_state`, and `_quote_escape` across buffer refills, but only 
rewinds `_idx` for `NORMAL` / `MATCH_ENCLOSE` on the next call. If the first 
pass ends after the first separator byte (for example a long row with 
`enclose=':'`, `sep='::'`, bytes `...alpha::` at the end of the current output 
chunk), `remaining < _column_sep_len` so we fall through to the old 
double-enclose path, consume that `:`, and never reconsider it after the 
refill. The second pass resumes at the second `:`, misses the separator, and 
`csv_reader` records one fewer column boundary. Please defer consumption until 
the full separator is available, or add equivalent rewind handling for 
`PRE_MATCH_ENCLOSE`.



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