vibhatha commented on code in PR #41646:
URL: https://github.com/apache/arrow/pull/41646#discussion_r1605595656


##########
cpp/src/arrow/dataset/file_csv.cc:
##########
@@ -503,5 +507,31 @@ Future<> CsvFileWriter::FinishInternal() {
   return Status::OK();
 }
 
+Result<std::shared_ptr<FragmentScanOptions>> CsvFragmentScanOptions::from(
+    const std::unordered_map<std::string, std::string>& configs) {
+  std::shared_ptr<CsvFragmentScanOptions> options =
+      std::make_shared<CsvFragmentScanOptions>();
+  for (auto const& it : configs) {
+    auto& key = it.first;
+    auto& value = it.second;
+    if (key == "delimiter") {
+      options->parse_options.delimiter = value.data()[0];
+    } else if (key == "quoting") {
+      options->parse_options.quoting = parseBool(value);
+    } else if (key == "column_type") {
+      int64_t schema_address = std::stol(value);
+      ArrowSchema* cSchema = reinterpret_cast<ArrowSchema*>(schema_address);
+      ARROW_ASSIGN_OR_RAISE(auto schema, arrow::ImportSchema(cSchema));
+      auto column_types = options->convert_options.column_types;
+      for (auto field : schema->fields()) {
+        column_types[field->name()] = field->type();
+      }
+    } else {
+      return Status::Invalid("Not support this config " + it.first);

Review Comment:
   Maybe:
   ```suggestion
         return Status::Invalid("Config " + it.first + " is not supported.");
   ```



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

Reply via email to