@@ -417,42 +417,37 @@ void ArrowConverter::ToArrowSchema(ArrowSchema *out_schema, const vector<Logical
417417 const vector<string> &names, ClientProperties &options) {
418418 D_ASSERT (out_schema);
419419 D_ASSERT (types.size () == names.size ());
420- D_ASSERT (options.client_context );
421- // We need to run this in a transaction. The arrow schema callback might use the catalog to do lookups.
422- options.client_context ->RunFunctionInTransaction ([&types, &out_schema, &names, &options]() {
423- const idx_t column_count = types.size ();
424- // Allocate as unique_ptr first to clean-up properly on error
425- auto root_holder = make_uniq<DuckDBArrowSchemaHolder>();
420+ const idx_t column_count = types.size ();
421+ // Allocate as unique_ptr first to clean-up properly on error
422+ auto root_holder = make_uniq<DuckDBArrowSchemaHolder>();
426423
427- // Allocate the children
428- root_holder->children .resize (column_count);
429- root_holder->children_ptrs .resize (column_count, nullptr );
430- for (size_t i = 0 ; i < column_count; ++i) {
431- root_holder->children_ptrs [i] = &root_holder->children [i];
432- }
433- out_schema->children = root_holder->children_ptrs .data ();
434- out_schema->n_children = NumericCast<int64_t >(column_count);
424+ // Allocate the children
425+ root_holder->children .resize (column_count);
426+ root_holder->children_ptrs .resize (column_count, nullptr );
427+ for (size_t i = 0 ; i < column_count; ++i) {
428+ root_holder->children_ptrs [i] = &root_holder->children [i];
429+ }
430+ out_schema->children = root_holder->children_ptrs .data ();
431+ out_schema->n_children = NumericCast<int64_t >(column_count);
435432
436- // Store the schema
437- out_schema->format = " +s" ; // struct apparently
438- out_schema->flags = 0 ;
439- out_schema->metadata = nullptr ;
440- out_schema->name = " duckdb_query_result" ;
441- out_schema->dictionary = nullptr ;
433+ // Store the schema
434+ out_schema->format = " +s" ; // struct apparently
435+ out_schema->flags = 0 ;
436+ out_schema->metadata = nullptr ;
437+ out_schema->name = " duckdb_query_result" ;
438+ out_schema->dictionary = nullptr ;
442439
443- // Configure all child schemas
444- for (idx_t col_idx = 0 ; col_idx < column_count; col_idx++) {
445- root_holder->owned_column_names .push_back (AddName (names[col_idx]));
446- auto &child = root_holder->children [col_idx];
447- InitializeChild (child, *root_holder, names[col_idx]);
448- SetArrowFormat (*root_holder, child, types[col_idx], options, *options.client_context );
449- }
450-
451- // Release ownership to caller
452- out_schema->private_data = root_holder.release ();
453- out_schema->release = ReleaseDuckDBArrowSchema;
454- });
440+ // Configure all child schemas
441+ for (idx_t col_idx = 0 ; col_idx < column_count; col_idx++) {
442+ root_holder->owned_column_names .push_back (AddName (names[col_idx]));
443+ auto &child = root_holder->children [col_idx];
444+ InitializeChild (child, *root_holder, names[col_idx]);
445+ SetArrowFormat (*root_holder, child, types[col_idx], options, *options.client_context );
446+ }
455447
448+ // Release ownership to caller
449+ out_schema->private_data = root_holder.release ();
450+ out_schema->release = ReleaseDuckDBArrowSchema;
456451}
457452
458453} // namespace duckdb
0 commit comments