|
| 1 | +package issues |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "fmt" |
| 6 | + "testing" |
| 7 | + |
| 8 | + "github.com/ClickHouse/clickhouse-go/v2" |
| 9 | + clickhouse_tests "github.com/ClickHouse/clickhouse-go/v2/tests" |
| 10 | + "github.com/stretchr/testify/assert" |
| 11 | + "github.com/stretchr/testify/require" |
| 12 | +) |
| 13 | + |
| 14 | +func Test1127(t *testing.T) { |
| 15 | + var ( |
| 16 | + conn, err = clickhouse_tests.GetConnection("issues", clickhouse.Settings{ |
| 17 | + "max_execution_time": 60, |
| 18 | + "allow_experimental_object_type": true, |
| 19 | + }, nil, &clickhouse.Compression{ |
| 20 | + Method: clickhouse.CompressionLZ4, |
| 21 | + }) |
| 22 | + ) |
| 23 | + require.NoError(t, err) |
| 24 | + |
| 25 | + progressTotalRows := uint64(0) |
| 26 | + profileTotalRows := uint64(0) |
| 27 | + ctx := clickhouse.Context(context.Background(), clickhouse.WithProgress(func(p *clickhouse.Progress) { |
| 28 | + fmt.Println("progress: ", p) |
| 29 | + progressTotalRows += p.Rows |
| 30 | + }), clickhouse.WithProfileInfo(func(p *clickhouse.ProfileInfo) { |
| 31 | + fmt.Println("profile info: ", p) |
| 32 | + profileTotalRows += p.Rows |
| 33 | + }), clickhouse.WithLogs(func(log *clickhouse.Log) { |
| 34 | + fmt.Println("log info: ", log) |
| 35 | + })) |
| 36 | + |
| 37 | + rows, err := conn.Query(ctx, "SELECT number from numbers(10000000) LIMIT 10000000") |
| 38 | + require.NoError(t, err) |
| 39 | + |
| 40 | + defer rows.Close() |
| 41 | + for rows.Next() { |
| 42 | + } |
| 43 | + |
| 44 | + require.NoError(t, rows.Err()) |
| 45 | + assert.Equal(t, uint64(10000000), progressTotalRows) |
| 46 | + assert.Equal(t, uint64(10000000), profileTotalRows) |
| 47 | +} |
0 commit comments