Skip to content

Commit adacabd

Browse files
committed
add interval col impl
1 parent b0ea1cc commit adacabd

7 files changed

Lines changed: 680 additions & 206 deletions

File tree

plugins/destination/postgresql/client/client_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func getTestData() map[string]interface{} {
2929
"string_array_column": []interface{}{"test", "test2"},
3030
"int_array_column": []interface{}{float64(1), float64(2), float64(3)},
3131
"timestamp_column": "2019-01-01T00:00:00",
32+
"interval_column": "01:02:03",
3233
"json_column": map[string]interface{}{"1": float64(1), "test": "test"},
3334
"uuid_array_column": []interface{}{"1a6011b7-c5ee-4b55-95a6-37ce5e02a5a0", "9a6011b7-c5ee-4b55-95a6-37ce5e02a5a0"},
3435
"inet_column": "1.1.1.1",
@@ -89,6 +90,10 @@ func getTestTable() *schema.Table {
8990
Name: "timestamp_column",
9091
Type: schema.TypeTimestamp,
9192
},
93+
{
94+
Name: "interval_column",
95+
Type: schema.TypeTimeInterval,
96+
},
9297
{
9398
Name: "json_column",
9499
Type: schema.TypeJSON,

plugins/destination/postgresql/client/drop.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import (
1010

1111
const sqlDropTable = "drop table if exists "
1212

13-
func (p *Client) Drop(ctx context.Context, tables schema.Tables) error {
14-
p.logger.Info().Strs("tables", tables.TableNames()).Msg("Dropping tables")
13+
func (c *Client) Drop(ctx context.Context, tables schema.Tables) error {
14+
c.logger.Info().Strs("tables", tables.TableNames()).Msg("Dropping tables")
1515
for _, table := range tables {
1616
var tableName pgx.Identifier = []string{table.Name}
17-
if _, err := p.conn.Exec(ctx, sqlDropTable+tableName.Sanitize()); err != nil {
17+
if _, err := c.conn.Exec(ctx, sqlDropTable+tableName.Sanitize()); err != nil {
1818
return fmt.Errorf("failed to drop table %s: %w", table.Name, err)
1919
}
2020
}

plugins/destination/postgresql/client/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ func (*Client) SchemaTypeToPg10(t schema.ValueType) string {
2929
return "text[]"
3030
case schema.TypeTimestamp:
3131
return "timestamp without time zone"
32+
case schema.TypeTimeInterval:
33+
return "interval(6)"
3234
case schema.TypeJSON:
3335
return "jsonb"
3436
case schema.TypeUUIDArray:
@@ -68,6 +70,8 @@ func (*Client) SchemaTypeToCockroach(t schema.ValueType) string {
6870
return "text[]"
6971
case schema.TypeTimestamp:
7072
return "timestamp without time zone"
73+
case schema.TypeTimeInterval:
74+
return "interval(6)"
7175
case schema.TypeJSON:
7276
return "jsonb"
7377
case schema.TypeUUIDArray:

plugins/destination/postgresql/go.mod

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ require (
1515
require (
1616
github.com/cloudquery/faker/v3 v3.7.7 // indirect
1717
github.com/davecgh/go-spew v1.1.1 // indirect
18-
github.com/getsentry/sentry-go v0.13.0 // indirect
18+
github.com/getsentry/sentry-go v0.14.0 // indirect
1919
github.com/ghodss/yaml v1.0.0 // indirect
2020
github.com/gofrs/uuid v4.3.0+incompatible // indirect
2121
github.com/golang/protobuf v1.5.2 // indirect
22-
github.com/grpc-ecosystem/go-grpc-middleware/providers/zerolog/v2 v2.0.0-rc.2 // indirect
23-
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0-rc.2 // indirect
22+
github.com/grpc-ecosystem/go-grpc-middleware/providers/zerolog/v2 v2.0.0-rc.3 // indirect
23+
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0-rc.3 // indirect
2424
github.com/inconshreveable/mousetrap v1.0.1 // indirect
2525
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
2626
github.com/jackc/pgconn v1.13.0 // indirect
@@ -34,20 +34,20 @@ require (
3434
github.com/modern-go/reflect2 v1.0.2 // indirect
3535
github.com/pmezard/go-difflib v1.0.0 // indirect
3636
github.com/spf13/cast v1.5.0 // indirect
37-
github.com/spf13/cobra v1.5.0 // indirect
37+
github.com/spf13/cobra v1.6.0 // indirect
3838
github.com/spf13/pflag v1.0.5 // indirect
3939
github.com/stretchr/testify v1.8.0 // indirect
4040
github.com/thoas/go-funk v0.9.2 // indirect
4141
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
4242
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
4343
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
44-
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
45-
golang.org/x/net v0.0.0-20220920203100-d0c6ba3f52d9 // indirect
44+
golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2 // indirect
45+
golang.org/x/net v0.0.0-20221004154528-8021a29435af // indirect
4646
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0 // indirect
47-
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect
48-
golang.org/x/text v0.3.7 // indirect
49-
google.golang.org/genproto v0.0.0-20220920201722-2b89144ce006 // indirect
50-
google.golang.org/grpc v1.49.0 // indirect
47+
golang.org/x/sys v0.0.0-20221010170243-090e33056c14 // indirect
48+
golang.org/x/text v0.3.8 // indirect
49+
google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e // indirect
50+
google.golang.org/grpc v1.50.0 // indirect
5151
google.golang.org/protobuf v1.28.1 // indirect
5252
gopkg.in/yaml.v2 v2.4.0 // indirect
5353
gopkg.in/yaml.v3 v3.0.1 // indirect

0 commit comments

Comments
 (0)