Skip to content

Go SQL driver: unable to handle time.Time values #3103

@srimal-randoli

Description

@srimal-randoli

What would you like help with?

I'm trying to access a FlightSQL server created using GizmoSQL(https://github.com/gizmodata/gizmosql) with a DuckDB Backend. And it seems that the go driver is unable to handle time.Time values properly when I try to pass them to a parameterized query.

Here is my code.

package main

import (
	"context"
	"database/sql"
	"fmt"
	"log"
	"testing"
	"time"

	_ "github.com/apache/arrow-adbc/go/adbc/sqldriver/flightsql"
)

var dsnTemplate = "uri=grpc://%s;username=%s;password=%s"

const (
	FLIGHT_SQL_USER = "gizmosql_username"
	FLIGHT_SQL_PASS = "password123"
	FLIGHT_SQL_HOST = "localhost:31337"
)

// This example uses Go's native SQL driver
func TestFlightSQL(t *testing.T) {
	dsn := fmt.Sprintf(dsnTemplate,
		FLIGHT_SQL_HOST,
		FLIGHT_SQL_USER,
		FLIGHT_SQL_PASS,
	)

	db, err := sql.Open("flightsql", dsn)
	if err != nil {
		log.Fatalf("opening a connection failed: %v", err)
	}

	defer db.Close()

	timestamp := time.Now()

	// Table schema
	// CREATE TABLE IF NOT EXISTS flight_test.events (id INTEGER, event_time TIMESTAMP)
	result, err := db.ExecContext(context.Background(), `INSERT INTO flight_test.events (id, event_time) VALUES (1, $1)`, timestamp)
	if err != nil {
		log.Fatal(err)
	}

	log.Print(result)
}

And this is the output


=== RUN   TestFlightSQL
2025/07/06 07:13:16 sql: converting argument $1 type: Invalid Argument: expected parameter of type timestamp[us]
FAIL	gitlab.com/srimaln91/flight-sql-client	0.046s

Dependancies being used.

	github.com/apache/arrow-adbc/go/adbc v1.6.0
	github.com/apache/arrow-go/v18 v18.2.0

Any help would be much appreciated. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions