Skip to content

Commit

Permalink
fixup! feat: sqlconnect library
Browse files Browse the repository at this point in the history
  • Loading branch information
atzoum committed Feb 20, 2024
1 parent edce9eb commit 863c52a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions sqlconnect/internal/trino/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

func TestTrinoDB(t *testing.T) {
t.Setenv("TZ", "UTC") // set timezone to UTC for consistent datetime tests
configJSON, ok := os.LookupEnv("TRINO_TEST_ENVIRONMENT_CREDENTIALS")
if !ok {
t.Skip("skipping trino integration test due to lack of a test environment")
Expand Down
6 changes: 5 additions & 1 deletion sqlconnect/internal/trino/mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"regexp"
"strconv"
"strings"
"time"

"github.com/rudderlabs/sqlconnect-go/sqlconnect/internal/base"
)
Expand Down Expand Up @@ -71,6 +72,9 @@ func jsonRowMapper(databaseTypeName string, value any) any {
return string(v)

Check warning on line 72 in sqlconnect/internal/trino/mappings.go

View check run for this annotation

Codecov / codecov/patch

sqlconnect/internal/trino/mappings.go#L71-L72

Added lines #L71 - L72 were not covered by tests
}
}

switch v := value.(type) {
case time.Time:
return v.UTC()
}
return value
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"_char": "abc",
"_varbinary": "YWJj",
"_boolean": true,
"_date": "2004-10-19T00:00:00+03:00",
"_timestamp": "2004-10-19T10:23:54+03:00",
"_date": "2004-10-19T00:00:00Z",
"_timestamp": "2004-10-19T10:23:54Z",
"_array": [
1,
2,
Expand All @@ -39,8 +39,8 @@
"_char": " ",
"_varbinary": "",
"_boolean": false,
"_date": "2004-10-19T00:00:00+03:00",
"_timestamp": "2004-10-19T10:23:54+03:00",
"_date": "2004-10-19T00:00:00Z",
"_timestamp": "2004-10-19T10:23:54Z",
"_array": [],
"_map": {
"bar": 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ CREATE TABLE "{{.schema}}"."column_mappings_test" (
INSERT INTO "{{.schema}}"."column_mappings_test"
(_order, _int, _tinyint, _smallint, _integer, _bigint, _real, _double, _decimal, _varchar, _char, _varbinary, _boolean, _date, _timestamp, _array, _map)
VALUES
(1, 1, TINYINT '1', SMALLINT '1', 1, BIGINT '1', REAL '1.1', DOUBLE '1.1', DECIMAL '1.1', 'abc', CHAR 'abc', VARBINARY 'abc', true, DATE '2004-10-19', TIMESTAMP '2004-10-19 10:23:54', ARRAY[1, 2, 3], MAP(ARRAY['foo', 'bar'], ARRAY[1, 2]) ),
(2, 0, TINYINT '0', SMALLINT '0', 0, BIGINT '0', REAL '0', DOUBLE '0', DECIMAL '0', '', CHAR '', VARBINARY '', false, DATE '2004-10-19', TIMESTAMP '2004-10-19 10:23:54', ARRAY[], MAP(ARRAY['foo', 'bar'], ARRAY[1, 2]) ),
(1, 1, TINYINT '1', SMALLINT '1', 1, BIGINT '1', REAL '1.1', DOUBLE '1.1', DECIMAL '1.1', 'abc', CHAR 'abc', VARBINARY 'abc', true, DATE '2004-10-19', TIMESTAMP '2004-10-19 10:23:54 UTC', ARRAY[1, 2, 3], MAP(ARRAY['foo', 'bar'], ARRAY[1, 2]) ),
(2, 0, TINYINT '0', SMALLINT '0', 0, BIGINT '0', REAL '0', DOUBLE '0', DECIMAL '0', '', CHAR '', VARBINARY '', false, DATE '2004-10-19', TIMESTAMP '2004-10-19 10:23:54 UTC', ARRAY[], MAP(ARRAY['foo', 'bar'], ARRAY[1, 2]) ),
(3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL );

0 comments on commit 863c52a

Please sign in to comment.