Skip to content

Complex return types #27

@Nintorac

Description

@Nintorac

Having a bit of problem with complex types, maybe it's a bit too early for the extension template, but I'm learning a lot anyway.


https://github.com/Nintorac/duck_midly/blob/main/src/functions.rs#L25-L161

Here's the type annotation I've landed so far, finding it very difficult to construct the object, is there any guidance on how to maybe do this in a better way? Maybe construct it in arrow first and then pass that back to DuckDB?

With my manual construction efforts I'm seeing some strange outputs.

  1. Inactive Union Fields Contain Garbage Data
  • Issue: Inactive union fields contain uninitialized memory values instead of being null
  • Evidence: Test failure shows event.kind.midi.message.pitch_bend.bend has garbage data
    in a note_on event
  • Impact: Inactive fields return random values like 5e-324 instead of null/empty values
  1. Inconsistent Field Visibility
  • Issue: Direct field access works but parent struct access doesn't
  • Evidence: event.kind.midi.channel works, event.kind.midi shows None
  • Impact: Creates confusion about data availability and struct state

Tests here highlighting the issues

FWIW this could just be my very..very basic understanding of rust and a whole lotta AI slop thats landed me here.

Slightly related to some of the chat in #6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions