Skip to content

Align UDT handling in trino-go-client with Java client’s Base64-encoding default #145

@moraistejerina

Description

@moraistejerina

Summary

Today the two official Trino clients diverge in how they handle User-Defined Types (UDTs):

  • trino-java-client
    Defaults to serializing UDT values via a Base64 encoder, allowing arbitrary binary payloads to round-trip without error.
  • trino-go-client
    Treats any UDT as an unsupported type and immediately raises an exception when encountering one.

This mismatch causes cross-language interoperability issues and surprises Go users who expect the same “just works” behavior as in Java. We should align the Go client’s behavior to match the Java client: default to Base64-encoding UDT values, and only error if encoding itself fails.


Current Behavior

trino-go-client

  • Unsupported by default
    In (*stmt).NextColumnType, encountering a column with type.kind == “user_defined” will cause NextColumnType (or downstream type mapping) to return an error:

    return nil, fmt.Errorf("unsupported column type: %s", tc.String())

trino-java-client

  • Base64 encoder default
    In io.trino.client.StatementClient, UDT payloads are represented as opaque byte[] values, which the client maps to Base64 strings in JSON. When rows are fetched, those JSON Base64 values are decoded into Java’s byte[] and can be consumed via ResultSet.getBytes().
  • No error path
    Unless the Base64 itself is malformed, the Java client will never raise a “unsupported type” error for UDT columns.

Proposal

  1. Add a Base64 default converter for UDT columns in trino-go-client

    • In the column-type detection logic (e.g. in ColumnConverterForType), detect type.kind == user_defined and return a converter that:

      1. Reads the raw payload bytes
      2. Calls encoding/base64.StdEncoding.EncodeToString([]bytePayload)
      3. Returns the resulting string to the caller

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