Skip to content

Commit

Permalink
improve bcp test
Browse files Browse the repository at this point in the history
  • Loading branch information
flarco committed Aug 27, 2024
1 parent 09973ea commit 8dd5881
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cmd/sling/sling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ var connMap = map[dbio.Type]connTest{
dbio.TypeDbSnowflake: {name: "snowflake"},
dbio.TypeDbSQLite: {name: "sqlite", schema: "main"},
dbio.TypeDbSQLServer: {name: "mssql", schema: "dbo", useBulk: g.Bool(false)},
dbio.Type("sqlserver_bcp"): {name: "mssql", schema: "dbo", useBulk: g.Bool(true), adjustCol: g.Bool(false)},
dbio.TypeDbStarRocks: {name: "starrocks"},
dbio.TypeDbTrino: {name: "trino", adjustCol: g.Bool(false)},
dbio.TypeDbMongoDB: {name: "mongo", schema: "default"},
Expand Down Expand Up @@ -548,7 +549,8 @@ func TestSuiteDatabaseMotherDuck(t *testing.T) {

func TestSuiteDatabaseSQLServer(t *testing.T) {
t.Parallel()
testSuite(t, dbio.TypeDbSQLServer)
// testSuite(t, dbio.TypeDbSQLServer)
testSuite(t, dbio.Type("sqlserver_bcp"))
}

// func TestSuiteDatabaseAzure(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion core/dbio/database/database_sqlserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ func (conn *MsSQLServerConn) BcpImportFileParrallel(tableFName string, ds *iop.D

filePath := path.Join(env.GetTempFolder(), g.NewTsID("sqlserver")+g.F("%d.csv", len(ds.Batches)))
csvRowCnt, err := writeCsvWithoutQuotes(filePath, batch, fileRowLimit)

if err != nil {
os.Remove(filePath)
err = g.Error(err, "Error csv.WriteStream(ds) to "+filePath)
Expand All @@ -339,7 +340,8 @@ func (conn *MsSQLServerConn) BcpImportFileParrallel(tableFName string, ds *iop.D
return 0, g.Error(err)
} else if csvRowCnt == 0 {
// no data from source
return 0, nil
os.Remove(filePath)
continue
}

ds.Context.Wg.Write.Add()
Expand Down

0 comments on commit 8dd5881

Please sign in to comment.