Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test pr 1211 #1254

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d11fc39
try to recreate the issue with UUID to solve #1209
ChronosMasterOfAllTime Sep 19, 2024
49e0ee5
[AB#1669514] fix UUID
ChronosMasterOfAllTime Sep 19, 2024
6d32e2c
[AB#1669514] remove commented code
ChronosMasterOfAllTime Sep 19, 2024
f8ebfc9
[AB#1669514] alternate approach; more generalized
ChronosMasterOfAllTime Sep 20, 2024
ba297f1
[AB#1669514] add stringer safe check; driver valuer check too
ChronosMasterOfAllTime Sep 20, 2024
70ae88a
[AB#1669514] Fix some comments
ChronosMasterOfAllTime Sep 20, 2024
442dc86
[AB#1669514] simplify stringer check
ChronosMasterOfAllTime Sep 20, 2024
5a4ba7d
[AB#1669514] simplify valuer
ChronosMasterOfAllTime Sep 20, 2024
ab7db31
[AB#1669514] move the driver valuer short circuit above the other typ…
ChronosMasterOfAllTime Sep 20, 2024
046ffa1
[AB#1669514] dont run stringer on everything arrays
ChronosMasterOfAllTime Sep 20, 2024
e37107e
[AB#1669514] add array check too
ChronosMasterOfAllTime Sep 20, 2024
ad715dd
[AB#1669514] jsonFmtStr and ignore debug binary
ChronosMasterOfAllTime Sep 20, 2024
fb98fdf
[AB#1669514] make it simpler
ChronosMasterOfAllTime Sep 20, 2024
e657e07
[AB#1669514] revert that change; wont handle complex types
ChronosMasterOfAllTime Sep 20, 2024
2989d2f
[AB#1669514] add test for SQL Null time
ChronosMasterOfAllTime Sep 23, 2024
1b944d2
[AB#1669514] make it simpler and mayyybe easier to understand
ChronosMasterOfAllTime Oct 8, 2024
ddb5544
[AB#1669514] even simpler
ChronosMasterOfAllTime Oct 8, 2024
42e8125
[AB#1669514] nil safety on err
ChronosMasterOfAllTime Oct 10, 2024
b450e5c
[AB#1669514] more complete converter checks
ChronosMasterOfAllTime Oct 10, 2024
8897942
[AB#1669514] structured read test
ChronosMasterOfAllTime Nov 19, 2024
74f145d
[AB#1669514] structured r/w tests
ChronosMasterOfAllTime Nov 19, 2024
4a1daa9
[AB#1669514] driver test?
ChronosMasterOfAllTime Nov 19, 2024
67caed6
[AB#1669514] fix driver test
ChronosMasterOfAllTime Nov 19, 2024
6d3b0a5
[AB#1669514] not quite right, but structured driver test is almost done
ChronosMasterOfAllTime Nov 19, 2024
077f4da
[AB#1669514] no hard dependencies on googleUUID
ChronosMasterOfAllTime Nov 20, 2024
c7632ec
[AB#1669514] move type to test file so it's not bundled
ChronosMasterOfAllTime Nov 20, 2024
ad6741a
[AB#1669514] dont commit the commented query too large to print error
ChronosMasterOfAllTime Nov 20, 2024
11ce50b
[AB#1669514] debug mode for local help
ChronosMasterOfAllTime Nov 20, 2024
53d5ad4
[AB#1669514] bump checkout; fix typo in yaml
ChronosMasterOfAllTime Nov 20, 2024
74c6fd8
[AB#1669514] Notes in bind_uploader
ChronosMasterOfAllTime Nov 20, 2024
088bfdc
[AB#1669514] dont commit formatting
ChronosMasterOfAllTime Nov 20, 2024
03840ad
[AB#1669514] data.Message fix
ChronosMasterOfAllTime Nov 21, 2024
06a86c1
[AB#1669514] revert atoierr
ChronosMasterOfAllTime Nov 21, 2024
9783b9c
[AB#1669514] JSON test vs basic type
ChronosMasterOfAllTime Nov 21, 2024
afd6995
[AB#1669514] arrow test
ChronosMasterOfAllTime Nov 21, 2024
36c4510
[AB#1669514] fix array binding
ChronosMasterOfAllTime Nov 22, 2024
ca28347
[AB#1669514] make it slightly faster by using nlogn complexity
ChronosMasterOfAllTime Nov 22, 2024
22740b4
back to 100K
ChronosMasterOfAllTime Nov 22, 2024
f5fe4a8
[AB#1669514] simplify if check in test
ChronosMasterOfAllTime Nov 22, 2024
f342a0a
[AB#1669514] More performant sort
ChronosMasterOfAllTime Nov 22, 2024
380db14
[AB#1669514] use internal assert method
ChronosMasterOfAllTime Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and Test

on:
push:
braches:
branches:
- master
tags:
- v*
Expand Down Expand Up @@ -30,11 +30,11 @@ jobs:
fail-fast: false
name: Check linter
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version-file: "./go.mod"
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
Expand All @@ -51,7 +51,7 @@ jobs:
go: [ '1.21', '1.22', '1.23' ]
name: ${{ matrix.cloud }} Go ${{ matrix.go }} on Ubuntu
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
Expand All @@ -77,7 +77,7 @@ jobs:
go: [ '1.21', '1.22', '1.23' ]
name: ${{ matrix.cloud }} Go ${{ matrix.go }} on Mac
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
Expand All @@ -102,7 +102,7 @@ jobs:
go: [ '1.21', '1.22', '1.23' ]
name: ${{ matrix.cloud }} Go ${{ matrix.go }} on Windows
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea/
.vscode/
parameters*.json
parameters*.bat
*.p8
Expand All @@ -11,6 +12,8 @@ wss-golang-agent.config
wss-unified-agent.jar
whitesource/
*.swp
cp.out
__debug_bin*

# exclude vendor
vendor
2 changes: 1 addition & 1 deletion bind_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (bu *bindUploader) createStageIfNeeded() error {
return (&SnowflakeError{
Number: code,
SQLState: data.Data.SQLState,
Message: err.Error(),
Message: data.Message,
QueryID: data.Data.QueryID,
}).exceptionTelemetry(bu.sc)
}
Expand Down
111 changes: 89 additions & 22 deletions bindings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
"database/sql"
"fmt"
"log"
"math"
"math/big"
"math/rand"
"reflect"
"slices"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -70,7 +72,7 @@
dbt.mustExec("INSERT INTO test VALUES (1, ?)", expected)
rows = dbt.mustQuery("SELECT value FROM test WHERE id = ?", 1)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
if rows.Next() {
assertNilF(t, rows.Scan(&out))
Expand Down Expand Up @@ -203,14 +205,14 @@
dbt.Fatal(err.Error())
}
defer func() {
assertNilF(t, stmt.Close())
assertNilF(t, stmt.Close())
}()
if _, err = stmt.Exec(DataTypeTimestampTz, expected); err != nil {
dbt.Fatal(err)
}
rows := dbt.mustQuery("SELECT tz FROM tztest WHERE id=?", 1)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
var v time.Time
if rows.Next() {
Expand Down Expand Up @@ -258,7 +260,7 @@

rows := dbt.mustQuery("SELECT tz FROM timeStructTest WHERE id=?", &expectedID)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
var v time.Time
if rows.Next() {
Expand Down Expand Up @@ -307,7 +309,7 @@

rows := dbt.mustQuery("SELECT tz FROM timeStructTest WHERE id=?", &expectedID)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
var v time.Time
if rows.Next() {
Expand All @@ -329,7 +331,7 @@
rows := dbt.mustQueryContext(
WithHigherPrecision(context.Background()), selectVariousTypes)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
if !rows.Next() {
dbt.Error("failed to query")
Expand Down Expand Up @@ -357,7 +359,7 @@
runDBTest(t, func(dbt *DBTest) {
rows := dbt.mustQuery(selectVariousTypes)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
if !rows.Next() {
dbt.Error("failed to query")
Expand All @@ -382,6 +384,71 @@
})
}

func TestBulkArrayBindingUUID(t *testing.T) {
max := math.Pow10(5) // 100K because my power is maximum
expectedUuids := make([]any, int(max))

createTable := "CREATE OR REPLACE TABLE TEST_PREP_STATEMENT (uuid VARCHAR)"
insert := "INSERT INTO TEST_PREP_STATEMENT (uuid) VALUES (?)"

for i := range expectedUuids {
expectedUuids[i] = newTestUUID()
}

slices.SortStableFunc(expectedUuids, func(i, j any) int {
return strings.Compare(i.(testUUID).String(), j.(testUUID).String())
})

runDBTest(t, func(dbt *DBTest) {
var rows *RowsExtended
t.Cleanup(func() {
if rows != nil {
assertNilF(t, rows.Close())
}

dbt.exec(deleteTableSQL)

Check failure on line 409 in bindings_test.go

View workflow job for this annotation

GitHub Actions / Check linter

Error return value of `dbt.exec` is not checked (errcheck)
})

dbt.mustExec(createTable)

res := dbt.mustExec(insert, Array(&expectedUuids))

affected, err := res.RowsAffected()
if err != nil {
t.Fatalf("failed to get affected rows. err: %s", err)
} else if affected != int64(max) {
t.Fatalf("failed to insert all rows. expected: %f.0, got: %v", max, affected)
}

rows = dbt.mustQuery("SELECT * FROM TEST_PREP_STATEMENT ORDER BY uuid")
if rows == nil {
t.Fatal("failed to query")
}

if rows.Err() != nil {
t.Fatalf("failed to query. err: %s", rows.Err())
}

var actual = make([]testUUID, len(expectedUuids))

for i := 0; rows.Next(); i++ {
var (
out testUUID
)
if err := rows.Scan(&out); err != nil {
t.Fatal(err)
}

actual[i] = out
}

for i := range expectedUuids {
assertEqualE(t, actual[i], expectedUuids[i])
}
})

}

func TestBulkArrayBindingInterfaceNil(t *testing.T) {
nilArray := make([]any, 1)

Expand All @@ -396,7 +463,7 @@
Array(&nilArray, TimeType))
rows := dbt.mustQuery(selectAllSQL)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()

var v0 sql.NullInt32
Expand Down Expand Up @@ -481,7 +548,7 @@
Array(&boolArray), Array(&strArray), Array(&byteArray), Array(&int64Array))
rows := dbt.mustQuery(selectAllSQLBulkArray)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()

var v0 sql.NullInt32
Expand Down Expand Up @@ -586,7 +653,7 @@

rows := dbt.mustQuery(selectAllSQLBulkArrayDateTimeTimestamp)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()

var v0, v1, v2, v3, v4 sql.NullTime
Expand Down Expand Up @@ -695,7 +762,7 @@
Array(&tmArray, TimeType))
rows := dbt.mustQuery(selectAllSQL)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()

var v0 int
Expand Down Expand Up @@ -777,7 +844,7 @@
dbt.mustExec(fmt.Sprintf("insert into %v values (?, ?, ?, ?, ?, ?, ?, ?)", dbname), Array(&intArr), Array(&strArr), Array(&ltzArr, TimestampLTZType), Array(&tzArr, TimestampTZType), Array(&ntzArr, TimestampNTZType), Array(&dateArr, DateType), Array(&timeArr, TimeType), Array(&binArr))
rows := dbt.mustQuery("select * from " + dbname + " order by c1")
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
cnt := 0
var i int
Expand Down Expand Up @@ -825,7 +892,7 @@
dbt.mustExec(fmt.Sprintf("insert into %v values (?, ?, ?, ?)", dbname), Array(&secondsArr, TimeType), Array(&millisecondsArr, TimeType), Array(&microsecondsArr, TimeType), Array(&nanosecondsArr, TimeType))
rows := dbt.mustQuery("select * from " + dbname)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
cnt := 0
var s, ms, us, ns time.Time
Expand Down Expand Up @@ -866,7 +933,7 @@
Array(&randomStrings))
rows := dbt.mustQuery("select count(*) from " + tempTableName)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
if rows.Next() {
var count int
Expand All @@ -878,7 +945,7 @@

rows := dbt.mustQuery("select count(*) from " + tempTableName)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
if rows.Next() {
var count int
Expand Down Expand Up @@ -909,7 +976,7 @@

rows := dbt.mustQuery("select * from binding_test order by c1")
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
cnt := startNum
var i int
Expand Down Expand Up @@ -959,7 +1026,7 @@

rows := dbt.mustQuery("select * from binding_test order by c1,c2")
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
cnt := startNum
var i sql.NullInt32
Expand Down Expand Up @@ -1042,7 +1109,7 @@
t.Fatal(err)
}
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
if rows.Err() != nil {
t.Fatal(err)
Expand Down Expand Up @@ -1144,7 +1211,7 @@
t.Fatal(err)
}
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
if !rows.Next() {
t.Fatal("Expected to return a row")
Expand Down Expand Up @@ -1194,7 +1261,7 @@
rows, err := dbt.query(fmt.Sprintf("SELECT randstr(%v, 124)", testSize))
assertNilF(t, err)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
assertTrueF(t, rows.Next(), fmt.Sprintf("no rows returned for the LOB size %v", testSize))

Expand Down Expand Up @@ -1227,7 +1294,7 @@
rows, err := dbt.query("select randstr(20000000, random())")
assertNilF(t, err)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
})
})
Expand Down Expand Up @@ -1308,7 +1375,7 @@
rows, err := dbt.query("SELECT * FROM lob_test_table")
assertNilF(t, err)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
assertTrueF(t, rows.Next(), fmt.Sprintf("%s: no rows returned", tc.testDesc))

Expand Down
Loading
Loading