From 9155c4953ba6fdf6cc5830a741924bb6b4e0ff4e Mon Sep 17 00:00:00 2001 From: Jan Was Date: Fri, 8 Jul 2022 20:33:04 +0200 Subject: [PATCH] Support row types --- trino/trino.go | 5 +++++ trino/trino_test.go | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/trino/trino.go b/trino/trino.go index 9d38b2d..910fc1f 100644 --- a/trino/trino.go +++ b/trino/trino.go @@ -1019,6 +1019,11 @@ func (c *typeConverter) ConvertValue(v interface{}) (driver.Value, error) { return nil, err } return v, nil + case "row": + if err := validateSlice(v); err != nil { + return nil, err + } + return v, nil default: return nil, fmt.Errorf("type not supported: %q", c.typeName) } diff --git a/trino/trino_test.go b/trino/trino_test.go index e0879e4..366ef21 100644 --- a/trino/trino_test.go +++ b/trino/trino_test.go @@ -461,6 +461,22 @@ func TestTypeConversion(t *testing.T) { ResponseUnmarshalledSample: nil, ExpectedGoValue: nil, }, + { + // rows return data as-is for slice scanners + DataType: "row(int, varchar(1), timestamp, array(varchar(1)))", + ResponseUnmarshalledSample: []interface{}{ + json.Number("1"), + "a", + "2017-07-10 01:02:03.000 UTC", + []interface{}{"b"}, + }, + ExpectedGoValue: []interface{}{ + json.Number("1"), + "a", + "2017-07-10 01:02:03.000 UTC", + []interface{}{"b"}, + }, + }, } for _, tc := range testcases {