18
18
package tests
19
19
20
20
import (
21
- "sync/atomic"
22
21
"testing"
23
22
24
23
"github.com/ClickHouse/clickhouse-go/v2"
@@ -32,14 +31,7 @@ import (
32
31
func TestBatchAppendRows (t * testing.T ) {
33
32
te , err := GetTestEnvironment (testSet )
34
33
require .NoError (t , err )
35
- blocksRead := atomic.Uint64 {}
36
34
opts := ClientOptionsFromEnv (te , clickhouse.Settings {})
37
- opts .Debug = true
38
- opts .Debugf = func (format string , args ... interface {}) {
39
- if format == "[batch.appendRowsBlocks] blockNum = %d" {
40
- blocksRead .Store (uint64 (args [0 ].(int ))) // store the last block number read from rows
41
- }
42
- }
43
35
44
36
conn , err := GetConnectionWithOptions (& opts )
45
37
require .NoError (t , err )
@@ -49,19 +41,14 @@ func TestBatchAppendRows(t *testing.T) {
49
41
// given we have two tables and a million rows in the source table
50
42
var tables = []string {"source" , "target" }
51
43
for _ , table := range tables {
52
- require .NoError (t , conn .Exec (context .Background (), "create table if not exists " + table + " (number1 Int, number2 String, number3 Tuple(String, Int), number4 DateTime) engine = MergeTree() order by tuple ()" ))
44
+ require .NoError (t , conn .Exec (context .Background (), "create table if not exists " + table + " (number1 Int, number2 String, number3 Tuple(String, Int), number4 DateTime) engine = Memory ()" ))
53
45
defer conn .Exec (context .Background (), "drop table if exists " + table )
54
46
}
55
47
56
48
require .NoError (t , conn .Exec (ctx , "INSERT INTO source SELECT number, 'string', tuple('foo', number), now() FROM system.numbers LIMIT 1000000" ))
57
49
58
50
// when we create a batch with direct data block access 10 times
59
-
60
- selectCtx := clickhouse .Context (ctx , clickhouse .WithSettings (clickhouse.Settings {
61
- "max_block_size" : 1000 ,
62
- }))
63
-
64
- sourceRows , err := conn .Query (selectCtx , "SELECT * FROM source" )
51
+ sourceRows , err := conn .Query (ctx , "SELECT * FROM source" )
65
52
require .NoError (t , err )
66
53
defer sourceRows .Close ()
67
54
@@ -75,6 +62,5 @@ func TestBatchAppendRows(t *testing.T) {
75
62
require .NoError (t , row .Err ())
76
63
var count uint64
77
64
require .NoError (t , row .Scan (& count ))
78
- assert .Equal (t , uint64 (1000000 ), count )
79
- assert .Equal (t , uint64 (999 ), blocksRead .Load ())
65
+ assert .Equal (t , 1000000 , int (count ))
80
66
}
0 commit comments