Skip to content

Commit

Permalink
Send quoting settings with CsvSettings (ydb-platform#4210)
Browse files Browse the repository at this point in the history
  • Loading branch information
iddqdex authored May 1, 2024
1 parent e0cc2ab commit c4610d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ydb/core/grpc_services/rpc_load_rows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,13 @@ class TUploadColumnsRPCPublic : public NTxProxy::TUploadRowsBase<NKikimrServices
errorMessage = reader.status().ToString();
return false;
}
const auto& quoting = cvsSettings.quoting();
if (quoting.quote_char().length() > 1) {
errorMessage = TStringBuilder() << "Wrong quote char '" << quoting.quote_char() << "'";
return false;
}
const char qchar = quoting.quote_char().empty() ? '"' : quoting.quote_char().front();
reader->SetQuoting(!quoting.disabled(), qchar, !quoting.double_quote_disabled());
reader->SetSkipRows(skipRows);

if (!delimiter.empty()) {
Expand Down
7 changes: 7 additions & 0 deletions ydb/public/api/protos/ydb_formats.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ message ArrowBatchSettings {
}

message CsvSettings {
message Quoting {
bool disabled = 1;
bytes quote_char = 2;
bool double_quote_disabled = 3;
}

// Number of rows to skip before CSV data. It should be present only in the first upsert of CSV file.
uint32 skip_rows = 1;
// Fields delimiter in CSV file. It's "," if not set.
Expand All @@ -17,4 +23,5 @@ message CsvSettings {
bytes null_value = 3;
// First not skipped line is a CSV header (list of column names).
bool header = 4;
Quoting quoting = 5;
}

0 comments on commit c4610d9

Please sign in to comment.