@@ -355,12 +355,6 @@ void EmptyStreamRelease(ArrowArrayStream *stream) {
355355
356356void FactoryGetSchema (ArrowArrayStream *stream, ArrowSchema &schema) {
357357 stream->get_schema (stream, &schema);
358-
359- // Need to nullify the root schema's release function here, because streams don't allow us to set the release
360- // function. For the schema's children, we nullify the release functions in `duckdb_arrow_scan`, so we don't need to
361- // handle them again here. We set this to nullptr and not EmptySchemaRelease to prevent ArrowSchemaWrapper's
362- // destructor from destroying the schema (it's the caller's responsibility).
363- schema.release = nullptr ;
364358}
365359
366360int GetSchema (struct ArrowArrayStream *stream, struct ArrowSchema *out) {
@@ -370,7 +364,6 @@ int GetSchema(struct ArrowArrayStream *stream, struct ArrowSchema *out) {
370364 }
371365
372366 *out = *private_data->schema ;
373- out->release = EmptySchemaRelease;
374367 return DuckDBSuccess;
375368}
376369
@@ -406,7 +399,13 @@ const char *GetLastError(struct ArrowArrayStream *stream) {
406399
407400void Release (struct ArrowArrayStream *stream) {
408401 if (stream->private_data != nullptr ) {
409- delete reinterpret_cast <PrivateData *>(stream->private_data );
402+ auto private_data = reinterpret_cast <PrivateData *>(stream->private_data );
403+ if (private_data->schema && private_data->schema ->release ) {
404+ private_data->schema ->release (private_data->schema );
405+ private_data->schema = nullptr ;
406+ }
407+
408+ delete private_data;
410409 }
411410
412411 stream->private_data = nullptr ;
0 commit comments