Skip to content

Commit

Permalink
Extended primitives in PG
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalyisaev2 committed Jan 10, 2024
1 parent 7d730ab commit 46ed92d
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
cat coverage_unit_tests.out > coverage.out
cat coverage_integration_tests.out | grep -v 'mode: atomic' >> coverage.out
go tool cover -func=coverage.out
rm coverage_unit_tests.out coverage_integration_tests.out
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4-beta
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
args: ./app/... ./tests/...
args: ./app/... ./common/... ./tests/...

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ run: build
./fq-connector-go server -c ./example.conf

lint:
golangci-lint run ./app/... ./tests/...
golangci-lint run ./app/... ./common/... ./tests/...

unit_test:
go test -v ./app/...
Expand All @@ -31,3 +31,6 @@ test_coverage: integration_test_env

build_image_base:
docker build -t ghcr.io/ydb-platform/fq-connector-go:base -f ./Dockerfile.base .

cloc:
cloc ./app ./common ./tests --git
9 changes: 8 additions & 1 deletion tests/infra/datasource/matching.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ func matchArrays[EXPECTED common.ValueType, ACTUAL common.ArrowArrayType[EXPECTE
if expected[j] != nil {
require.Equal(
t, *expected[j], actual.Value(j),
fmt.Sprintf("column: %v\nexpected: %v\nactual: %v\n", columnName, expected, actual))
fmt.Sprintf(
"expected val: %v\nactual val: %v\ncolumn: %v\nexpected: %v\nactual: %v\n",
*expected[j],
actual.Value(j),
columnName,
expected,
actual),
)
} else {
require.True(t, actual.IsNull(j),
fmt.Sprintf("column: %v\nexpected: %v\nactual: %v\n", columnName, expected, actual))
Expand Down
4 changes: 2 additions & 2 deletions tests/infra/datasource/postgresql/init/init_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-E
INSERT INTO primitives VALUES (
false, 2, 3, DEFAULT, DEFAULT, 6, 7, 8, DEFAULT, DEFAULT, 11, 12, DEFAULT, DEFAULT,
15.15, 16.16, 17.17, 18.18, 'az', 'az', 'az', 'az',
'1988-11-20 12:55:28.123456', '1988-11-20');
'1988-11-20 12:55:28.123000', '1988-11-20');
INSERT INTO primitives VALUES (
true, -2, -3, DEFAULT, DEFAULT, -6, -7, -8, DEFAULT, DEFAULT, -11, -12, DEFAULT, DEFAULT,
-15.15, -16.16, -17.17, -18.18, 'буки', 'буки', 'буки', 'буки',
'1988-11-20 12:55:28.123456', '1988-11-20');
'2023-03-21 11:21:31.456000', '2023-03-21');
INSERT INTO primitives VALUES (
NULL, NULL, NULL, DEFAULT, DEFAULT, NULL,
NULL, NULL, DEFAULT, DEFAULT, NULL, NULL,
Expand Down
127 changes: 120 additions & 7 deletions tests/infra/datasource/postgresql/tables.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package postgresql

import (
"time"

"github.com/ydb-platform/ydb-go-genproto/protos/Ydb"

api_service_protos "github.com/ydb-platform/fq-connector-go/api/service/protos"
Expand Down Expand Up @@ -147,15 +149,126 @@ var Tables = map[string]*datasource.Table{
Records: []*datasource.Record{
{
Columns: []any{
[]*int32{ptr.Int32(1), ptr.Int32(2), ptr.Int32(3), ptr.Int32(4), ptr.Int32(5)},
[]*uint8{ptr.Uint8(0), ptr.Uint8(1), nil},
[]*int16{
ptr.Int16(2),
ptr.Int16(-2),
nil,
},
[]*int16{
ptr.Int16(3),
ptr.Int16(-3),
nil,
},
[]*int16{
ptr.Int16(1),
ptr.Int16(2),
ptr.Int16(3),
},
[]*int16{
ptr.Int16(1),
ptr.Int16(2),
ptr.Int16(3),
},
[]*int32{
ptr.Int32(6),
ptr.Int32(-6),
nil,
},
[]*int32{
ptr.Int32(7),
ptr.Int32(-7),
nil,
},
[]*int32{
ptr.Int32(8),
ptr.Int32(-8),
nil,
},
[]*int32{
ptr.Int32(1),
ptr.Int32(2),
ptr.Int32(3),
},
[]*int32{
ptr.Int32(1),
ptr.Int32(2),
ptr.Int32(3),
},
[]*int64{
ptr.Int64(11),
ptr.Int64(-11),
nil,
},
[]*int64{
ptr.Int64(12),
ptr.Int64(-12),
nil,
},
[]*int64{
ptr.Int64(1),
ptr.Int64(2),
ptr.Int64(3),
},
[]*int64{
ptr.Int64(1),
ptr.Int64(2),
ptr.Int64(3),
},
[]*float32{
ptr.Float32(15.15),
ptr.Float32(-15.15),
nil,
},
[]*float32{
ptr.Float32(16.16),
ptr.Float32(-16.16),
nil,
},
[]*float64{
ptr.Float64(17.17),
ptr.Float64(-17.17),
nil,
},
[]*float64{
ptr.Float64(18.18),
ptr.Float64(-18.18),
nil,
},
[]*[]byte{
ptr.T[[]byte]([]byte("az")),
ptr.T[[]byte]([]byte("буки")),
nil,
},
[]*string{
ptr.String("pg_a"),
ptr.String("pg_b"),
ptr.String("pg_c"),
ptr.String("pg_d"),
ptr.String("pg_e"),
ptr.String("az "),
ptr.String("буки "),
nil,
},
[]*string{
ptr.String("az"),
ptr.String("буки"),
nil,
},
[]*string{
ptr.String("az"),
ptr.String("буки"),
nil,
},
[]*uint64{
ptr.Uint64(common.MustTimeToYDBType[uint64](
common.TimeToYDBTimestamp, time.Date(1988, 11, 20, 12, 55, 28, 123000000, time.UTC))),
ptr.Uint64(common.MustTimeToYDBType[uint64](
common.TimeToYDBTimestamp, time.Date(2023, 03, 21, 11, 21, 31, 456000000, time.UTC))),
nil,
},
[]*uint16{
ptr.Uint16(common.MustTimeToYDBType[uint16](
common.TimeToYDBDate, time.Date(1988, 11, 20, 12, 55, 8, 0, time.UTC))),
ptr.Uint16(common.MustTimeToYDBType[uint16](
common.TimeToYDBDate, time.Date(2023, 03, 21, 11, 21, 31, 0, time.UTC))),
nil,
},
[]*int32{ptr.Int32(10), ptr.Int32(20), ptr.Int32(30), ptr.Int32(40), ptr.Int32(50)},
},
},
},
Expand Down

0 comments on commit 46ed92d

Please sign in to comment.