| 73 | /// but of the wrong type, an error is returned. |
| 74 | template <typename T> |
| 75 | arrow::Result<std::shared_ptr<T>> GetFragmentScanOptions( |
| 76 | const std::string& type_name, const ScanOptions* scan_options, |
| 77 | const std::shared_ptr<FragmentScanOptions>& default_options) { |
| 78 | auto source = default_options; |
| 79 | if (scan_options && scan_options->fragment_scan_options) { |
| 80 | source = scan_options->fragment_scan_options; |
| 81 | } |
| 82 | if (!source) { |
| 83 | return std::make_shared<T>(); |
| 84 | } |
| 85 | if (source->type_name() != type_name) { |
| 86 | return Status::Invalid("FragmentScanOptions of type ", source->type_name(), |
| 87 | " were provided for scanning a fragment of type ", type_name); |
| 88 | } |
| 89 | return ::arrow::internal::checked_pointer_cast<T>(source); |
| 90 | } |
| 91 | |
| 92 | class FragmentDataset : public Dataset { |
| 93 | public: |