Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(deps): update module github.com/trinodb/trino-go-client to v1 (#21845)

renovate[bot]80b958fe602a
diff --git a/backend/common/testcontainer/shared.go b/backend/common/testcontainer/shared.go
index bfe9a40805..5f9004d3ea 100644
--- a/backend/common/testcontainer/shared.go
+++ b/backend/common/testcontainer/shared.go
@@ -26,6 +26,7 @@ var (
sharedMongo = startOnce(getMongoDBContainer)
sharedOracle = startOnce(getOracleContainer)
sharedMySQL = startOnce(GetMySQLContainer)
+ sharedTrino = startOnce(getTrinoContainer)
sharedMariaDB = startOnce(mariaDBStarter("mariadb:11.8.8"))
// 10.7 is the oldest MariaDB release Bytebase supports.
sharedMariaDB107 = startOnce(mariaDBStarter("mariadb:10.7.8"))
@@ -97,6 +98,10 @@ func SharedPg17Container(t testing.TB) *Container { return shared(t, sharedPg17)
// tests reach with sslmode=verify-full and GetTLSCAPath.
func SharedTLSPgContainer(t testing.TB) *Container { return shared(t, sharedTLSPg) }
+// SharedTrinoContainer is SharedPgContainer for Trino. It carries no *sql.DB,
+// so a test builds its own DSN from GetHost, GetPort and GetUsername.
+func SharedTrinoContainer(t testing.TB) *Container { return shared(t, sharedTrino) }
+
// SharedMSSQLContainer is SharedPgContainer for SQL Server; tests take a database each.
// Its certificate is signed by the CA at GetTLSCAPath.
func SharedMSSQLContainer(t testing.TB) *Container { return shared(t, sharedMSSQL) }
diff --git a/backend/common/testcontainer/testcontainer.go b/backend/common/testcontainer/testcontainer.go
index e42e6afec8..1b540a67e1 100644
--- a/backend/common/testcontainer/testcontainer.go
+++ b/backend/common/testcontainer/testcontainer.go
@@ -323,6 +323,20 @@ func getMSSQLContainer(ctx context.Context) (retC *Container, retErr error) {
// getTiDBContainer starts TiDB, which speaks the MySQL protocol with no
// password on root.
+// getTrinoContainer starts Trino with its built-in memory connector, which needs
+// no catalog files. driver is left unset so this package does not link the Trino
+// client for every suite that imports it; a test opens its own connection from
+// the host, port and user.
+func getTrinoContainer(ctx context.Context) (*Container, error) {
+ return start(ctx, testcontainers.ContainerRequest{
+ Image: "trinodb/trino:482",
+ WaitingFor: wait.ForLog("SERVER STARTED").WithStartupTimeout(5 * time.Minute),
+ }, spec{
+ port: "8080/tcp",
+ username: "bytebase",
+ })
+}
+
func getTiDBContainer(ctx context.Context) (*Container, error) {
return start(ctx, testcontainers.ContainerRequest{
Image: "pingcap/tidb:v8.5.0",
diff --git a/backend/plugin/db/trino/main_test.go b/backend/plugin/db/trino/main_test.go
new file mode 100644
index 0000000000..b9da73b083
--- /dev/null
+++ b/backend/plugin/db/trino/main_test.go
@@ -0,0 +1,9 @@
+package trino
+
+import (
+ "testing"
+
+ "github.com/bytebase/bytebase/backend/common/testcontainer"
+)
+
+func TestMain(m *testing.M) { testcontainer.Main(m) }
diff --git a/backend/plugin/db/trino/query.go b/backend/plugin/db/trino/query.go
index 47860a27b8..891e01e45c 100644
--- a/backend/plugin/db/trino/query.go
+++ b/backend/plugin/db/trino/query.go
@@ -12,6 +12,18 @@ import (
"github.com/bytebase/bytebase/backend/plugin/db/util"
)
+// trinoTimeLayout renders a TIME the way Trino and PostgreSQL print one, which
+// is what a SQL client shows: the fraction when the column's type carries one,
+// and nothing when it does not. The nines trim trailing zeros and take the
+// decimal point with them, so TIME keeps 12:34:56 while TIME(3) keeps
+// 12:34:56.789 instead of losing it.
+//
+// A zoned time keeps its offset as well, since dropping it moves the instant.
+const (
+ trinoTimeLayout = "15:04:05.999999999"
+ trinoTimeTZLayout = trinoTimeLayout + "-07:00"
+)
+
func makeValueByTypeName(typeName string, _ *sql.ColumnType) any {
switch typeName {
case "VARCHAR", "TEXT", "CHAR", "TIMESTAMP", "TIMESTAMP WITH TIME ZONE", "TIMESTAMP WITHOUT TIME ZONE":
@@ -28,6 +40,11 @@ func makeValueByTypeName(typeName string, _ *sql.ColumnType) any {
// *sql.NullString below cannot hold, failing the whole query.
case "VARIANT":
return new(trino.Variant)
+ // The driver decodes these to time.Time. Left to the default below, Go
+ // renders them through *sql.NullString as RFC3339Nano, so a DATE came back
+ // as 2026-01-02T00:00:00Z and a TIME as 0000-01-01T12:34:56Z.
+ case "DATE", "TIME", "TIME WITH TIME ZONE":
+ return new(sql.NullTime)
default:
return new(sql.NullString)
}
@@ -88,6 +105,22 @@ func convertValue(typeName string, _ *sql.ColumnType, value any) *v1pb.RowValue
},
}
}
+ case *sql.NullTime:
+ if raw.Valid {
+ layout := trinoTimeLayout
+ switch typeName {
+ case "DATE":
+ layout = time.DateOnly
+ case "TIME WITH TIME ZONE":
+ layout = trinoTimeTZLayout
+ default:
+ }
+ return &v1pb.RowValue{
+ Kind: &v1pb.RowValue_StringValue{
+ StringValue: raw.Time.Format(layout),
+ },
+ }
+ }
case *trino.Variant:
// String is the JSON text the server returns for CAST(v AS JSON). A
// VARIANT null is valid and renders as "null", unlike a SQL NULL.
diff --git a/backend/plugin/db/trino/query_test.go b/backend/plugin/db/trino/query_test.go
index ffcd1f6867..36546d21cd 100644
--- a/backend/plugin/db/trino/query_test.go
+++ b/backend/plugin/db/trino/query_test.go
@@ -1,12 +1,20 @@
package trino
import (
+ "context"
"database/sql"
+ "fmt"
"testing"
+ "time"
+ "github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/require"
"github.com/trinodb/trino-go-client/trino"
+ "google.golang.org/protobuf/testing/protocmp"
+ "google.golang.org/protobuf/types/known/timestamppb"
+ "github.com/bytebase/bytebase/backend/common/testcontainer"
+ v1pb "github.com/bytebase/bytebase/backend/generated-go/v1"
"github.com/bytebase/bytebase/backend/plugin/db/util"
)
@@ -35,3 +43,63 @@ func TestConvertValueReadsAVariant(t *testing.T) {
require.False(t, variant.Valid)
require.Equal(t, util.NullRowValue, convertValue("VARIANT", nil, variant))
}
+
+func str(v string) *v1pb.RowValue {
+ return &v1pb.RowValue{Kind: &v1pb.RowValue_StringValue{StringValue: v}}
+}
+
+// TestQueryResultRendersTrinoTypes pins how a real Trino's values reach the
+// client, so a driver upgrade that changes a decoded Go type shows up as a
+// failing expectation rather than as a silently reshaped result. The driver
+// hands DATE and TIME a time.Time: before they had a destination of their own,
+// Go rendered them through *sql.NullString as RFC3339Nano, so a date read back
+// as "2026-01-02T00:00:00Z" and a time as "0000-01-01T12:34:56Z".
+func TestQueryResultRendersTrinoTypes(t *testing.T) {
+ ctx := context.Background()
+ c := testcontainer.SharedTrinoContainer(t)
+ db, err := sql.Open("trino", fmt.Sprintf(
+ "http://%s@%s:%s?catalog=memory&schema=default",
+ c.GetUsername(), c.GetHost(), c.GetPort()))
+ require.NoError(t, err)
+ defer db.Close()
+
+ tests := []struct {
+ name string
+ expr string
+ wantType string
+ want *v1pb.RowValue
+ }{
+ {"date", "DATE '2026-01-02'", "DATE", str("2026-01-02")},
+ {"time", "TIME '12:34:56'", "TIME", str("12:34:56")},
+ {"time with precision", "CAST('12:34:56.789' AS TIME(3))", "TIME", str("12:34:56.789")},
+ {"zoned time", "TIME '12:34:56 +02:00'", "TIME WITH TIME ZONE", str("12:34:56+02:00")},
+ {"zoned time with precision", "TIME '12:34:56.789 +02:00'", "TIME WITH TIME ZONE", str("12:34:56.789+02:00")},
+ {"timestamp", "TIMESTAMP '2026-01-02 12:34:56'", "TIMESTAMP", &v1pb.RowValue{
+ Kind: &v1pb.RowValue_TimestampValue{TimestampValue: &v1pb.RowValue_Timestamp{
+ GoogleTimestamp: timestamppb.New(time.Date(2026, 1, 2, 12, 34, 56, 0, time.UTC)),
+ Accuracy: 6,
+ }},
+ }},
+ {"varchar", "CAST('hi' AS VARCHAR)", "VARCHAR", str("hi")},
+ {"bigint", "CAST(42 AS BIGINT)", "BIGINT", &v1pb.RowValue{Kind: &v1pb.RowValue_Int64Value{Int64Value: 42}}},
+ {"boolean", "true", "BOOLEAN", &v1pb.RowValue{Kind: &v1pb.RowValue_BoolValue{BoolValue: true}}},
+ {"decimal", "CAST(1.25 AS DECIMAL(5,2))", "DECIMAL", &v1pb.RowValue{Kind: &v1pb.RowValue_DoubleValue{DoubleValue: 1.25}}},
+ {"null date", "CAST(NULL AS DATE)", "DATE", util.NullRowValue},
+ {"null varchar", "CAST(NULL AS VARCHAR)", "VARCHAR", util.NullRowValue},
+ }
+
+ for _, tc := range tests {
+ t.Run(tc.name, func(t *testing.T) {
+ rows, err := db.QueryContext(ctx, "SELECT "+tc.expr)
+ require.NoError(t, err)
+ defer rows.Close()
+
+ result, err := util.RowsToQueryResult(rows, makeValueByTypeName, convertValue, 1<<20)
+ require.NoError(t, err)
+ require.NoError(t, rows.Err())
+ require.Len(t, result.Rows, 1)
+ require.Equal(t, tc.wantType, result.ColumnTypeNames[0])
+ require.Empty(t, cmp.Diff(tc.want, result.Rows[0].Values[0], protocmp.Transform()))
+ })
+ }
+}
diff --git a/go.mod b/go.mod
index e7d8695af5..f97036cb98 100644
--- a/go.mod
+++ b/go.mod
@@ -94,7 +94,7 @@ require (
github.com/stripe/stripe-go/v86 v86.4.2
github.com/testcontainers/testcontainers-go v0.44.0
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75
- github.com/trinodb/trino-go-client v0.338.0
+ github.com/trinodb/trino-go-client v1.4.1
github.com/vjeantet/ldapserver v1.0.1
github.com/xuri/excelize/v2 v2.11.1
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78
@@ -240,7 +240,7 @@ require (
github.com/hashicorp/go-secure-stdlib/parseutil v0.2.0 // indirect
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect
github.com/hashicorp/go-sockaddr v1.0.7 // indirect
- github.com/hashicorp/go-uuid v1.0.3 // indirect
+ github.com/hashicorp/go-uuid v1.0.4 // indirect
github.com/hashicorp/go-version v1.9.0 // indirect
github.com/hashicorp/hcl v1.0.1-vault-7 // indirect
github.com/hjson/hjson-go/v4 v4.6.0 // indirect
@@ -259,7 +259,7 @@ require (
github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/json-iterator/go v1.1.12 // indirect
- github.com/klauspost/compress v1.20.1 // indirect
+ github.com/klauspost/compress v1.20.3 // indirect
github.com/klauspost/cpuid/v2 v2.2.11 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
@@ -291,7 +291,7 @@ require (
github.com/pb33f/jsonpath v0.8.4 // indirect
github.com/pb33f/ordered-map/v2 v2.3.2 // indirect
github.com/petermattis/goid v0.0.0-20250813065127-a731cc31b4fe // indirect
- github.com/pierrec/lz4/v4 v4.1.30 // indirect
+ github.com/pierrec/lz4/v4 v4.1.33 // indirect
github.com/pierrre/geohash v1.0.0 // indirect
github.com/pingcap/errors v0.11.5-0.20250523034308-74f78ae071ee // indirect
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 // indirect
diff --git a/go.sum b/go.sum
index f86db2f034..dbe9a69882 100644
--- a/go.sum
+++ b/go.sum
@@ -561,8 +561,9 @@ github.com/hashicorp/go-secure-stdlib/strutil v0.1.2/go.mod h1:Gou2R9+il93BqX25L
github.com/hashicorp/go-sockaddr v1.0.7 h1:G+pTkSO01HpR5qCxg7lxfsFEZaG+C0VssTy/9dbT+Fw=
github.com/hashicorp/go-sockaddr v1.0.7/go.mod h1:FZQbEYa1pxkQ7WLpyXJ6cbjpT8q0YgQaK/JakXqGyWw=
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
-github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
+github.com/hashicorp/go-uuid v1.0.4 h1:ZrN80XjMzpRYk+2FxMDy2A2zz0d5QjJ7GMFSkZLj12A=
+github.com/hashicorp/go-uuid v1.0.4/go.mod h1:x2Ds7vSkQ2n/yQj8Synnxmt0zt1l26uCAjxIhChisLU=
github.com/hashicorp/go-version v1.9.0 h1:CeOIz6k+LoN3qX9Z0tyQrPtiB1DFYRPfCIBtaXPSCnA=
github.com/hashicorp/go-version v1.9.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
@@ -659,8 +660,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/asmfmt v1.3.2 h1:4Ri7ox3EwapiOjCki+hw14RyKk201CN4rzyCJRFLpK4=
github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE=
-github.com/klauspost/compress v1.20.1 h1:T7kKElXUMXrUJ2E9QhQhxFtcK5rPyLdsGZvdbLMPdiQ=
-github.com/klauspost/compress v1.20.1/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
+github.com/klauspost/compress v1.20.3 h1:zWNoFqq/lSuYQRim3dUXlXeA0IqwuZGicdG5ZTfY5j4=
+github.com/klauspost/compress v1.20.3/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
github.com/klauspost/cpuid v1.3.1 h1:5JNjFYYQrZeKRJ0734q51WCEEn2huer72Dc7K+R/b6s=
github.com/klauspost/cpuid v1.3.1/go.mod h1:bYW4mA6ZgKPob1/Dlai2LviZJO7KGI3uoWLd42rAQw4=
github.com/klauspost/cpuid/v2 v2.2.11 h1:0OwqZRYI2rFrjS4kvkDnqJkKHdHaRnCm68/DY4OxRzU=
@@ -797,8 +798,8 @@ github.com/pb33f/testify v0.1.1/go.mod h1:keghMqOLECF1ENzESnfM+cwPcKN5uhTOpvbtjg
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4=
github.com/petermattis/goid v0.0.0-20250813065127-a731cc31b4fe h1:vHpqOnPlnkba8iSxU4j/CvDSS9J4+F4473esQsYLGoE=
github.com/petermattis/goid v0.0.0-20250813065127-a731cc31b4fe/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4=
-github.com/pierrec/lz4/v4 v4.1.30 h1:cchX8N2DVP668WkElI9QMwVyoNabLkq1LofDHFeIrdg=
-github.com/pierrec/lz4/v4 v4.1.30/go.mod h1:EoQMVJgeeEOMsCqCzqFm2O0cJvljX2nGZjcRIPL34O4=
+github.com/pierrec/lz4/v4 v4.1.33 h1:GjG1TJ1V4IzKP8L96muuuDNpTwd7D+l2ccXrjAbe014=
+github.com/pierrec/lz4/v4 v4.1.33/go.mod h1:7SE9MC2STkNtL4PIwGhjmyVwvILaGI9/COYQNBhKM/c=
github.com/pierrre/compare v1.0.2 h1:k4IUsHgh+dbcAOIWCfxVa/7G6STjADH2qmhomv+1quc=
github.com/pierrre/compare v1.0.2/go.mod h1:8UvyRHH+9HS8Pczdd2z5x/wvv67krDwVxoOndaIIDVU=
github.com/pierrre/geohash v1.0.0 h1:f/zfjdV4rVofTCz1FhP07T+EMQAvcMM2ioGZVt+zqjI=
@@ -987,8 +988,8 @@ github.com/tklauser/numcpus v0.12.0 h1:NR85qdvHA9pFse3x3weVZ0r0ST8R6l5RHbZrlRaqo
github.com/tklauser/numcpus v0.12.0/go.mod h1:ABHeXzJnr/qqwguhClkZKT1/8VABcYrsyUiUGobwWJg=
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 h1:6fotK7otjonDflCTK0BCfls4SPy3NcCVb5dqqmbRknE=
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75/go.mod h1:KO6IkyS8Y3j8OdNO85qEYBsRPuteD+YciPomcXdrMnk=
-github.com/trinodb/trino-go-client v0.338.0 h1:R8VM6hRrEvjEq4hCEERuP9KDYAKtarqPqU4rOW2Qu9Q=
-github.com/trinodb/trino-go-client v0.338.0/go.mod h1:P2ifOGs+M0b5QyVmTdA4TMWvF73FZqAfg49YqyEQZ2k=
+github.com/trinodb/trino-go-client v1.4.1 h1:3Q9Q2g3MghR2QC0OOLgvhq4pHsPrOZQ//cJ0tQ4xOOw=
+github.com/trinodb/trino-go-client v1.4.1/go.mod h1:xXaYKgarrr6C8/giUfoyVaTMGAJnFFT5sw7Qj7cE4fE=
github.com/twmb/murmur3 v1.1.6 h1:mqrRot1BRxm+Yct+vavLMou2/iJt0tNVTTC0QoIjaZg=
github.com/twmb/murmur3 v1.1.6/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ=
github.com/twpayne/go-geom v1.4.1 h1:LeivFqaGBRfyg0XJJ9pkudcptwhSSrYN9KZUW6HcgdA=