@@ -153,20 +153,18 @@ static void ExtractVortexSchema(const vx_dtype *file_dtype, vector<LogicalType>
153153
154154const std::regex schema_prefix = std::regex(" ^[^/]*:\\ /\\ /.*$" );
155155
156- std::string EnsureFileProtocol (const std::string &path) {
157- // Check if the path has a schema, if not prepend the file:// schema
156+ std::string EnsureFileProtocol (FileSystem &fs, const std::string &path) {
157+ // If the path is a URL then don't change it, otherwise try to make the path an absolute path
158158 if (std::regex_match (path, schema_prefix)) {
159159 return path;
160160 }
161161
162162 const std::string prefix = " file://" ;
163-
164- auto fs = FileSystem::CreateLocal ();
165- if (fs->IsPathAbsolute (path)) {
166- return path;
163+ if (fs.IsPathAbsolute (path)) {
164+ return prefix + path;
167165 }
168166
169- const auto absolute_path = fs-> JoinPath (fs-> GetWorkingDirectory (), path);
167+ const auto absolute_path = fs. JoinPath (fs. GetWorkingDirectory (), path);
170168 return prefix + absolute_path;
171169}
172170
@@ -209,13 +207,14 @@ static void VerifyNewFile(const VortexBindData &bind_data, vector<LogicalType> &
209207 }
210208}
211209
212- static unique_ptr<VortexFileReader> OpenFileAndVerify (const std::string &filename, const VortexBindData &bind_data) {
210+ static unique_ptr<VortexFileReader> OpenFileAndVerify (FileSystem &fs, const std::string &filename,
211+ const VortexBindData &bind_data) {
213212 auto new_column_names = vector<string>();
214213 new_column_names.reserve (bind_data.column_names .size ());
215214 auto new_column_types = vector<LogicalType>();
216215 new_column_names.reserve (bind_data.columns_types .size ());
217216
218- auto file = OpenFile (EnsureFileProtocol (filename), new_column_types, new_column_names);
217+ auto file = OpenFile (EnsureFileProtocol (fs, filename), new_column_types, new_column_names);
219218 VerifyNewFile (bind_data, new_column_types, new_column_names);
220219 return file;
221220}
@@ -268,7 +267,7 @@ static void VortexScanFunction(ClientContext &context, TableFunctionInput &data,
268267 }
269268
270269 auto file_name = global_state.expanded_files [file_idx];
271- auto file = OpenFileAndVerify (file_name, bind_data);
270+ auto file = OpenFileAndVerify (FileSystem::GetFileSystem (context), file_name, bind_data);
272271
273272 slot.array_stream = OpenArrayStream (bind_data, global_state, file.get ());
274273 }
@@ -309,7 +308,7 @@ static unique_ptr<FunctionData> VortexBind(ClientContext &context, TableFunction
309308 auto vec = duckdb::vector<string> {input.inputs [0 ].GetValue <string>()};
310309 result->file_list = make_shared_ptr<GlobMultiFileList>(context, vec, FileGlobOptions::DISALLOW_EMPTY);
311310
312- auto filename = EnsureFileProtocol (result->file_list ->GetFirstFile ());
311+ auto filename = EnsureFileProtocol (FileSystem::GetFileSystem (context), result->file_list ->GetFirstFile ());
313312
314313 result->initial_file = OpenFile (filename, column_types, column_names);
315314
0 commit comments