Skip to content

Commit 6985077

Browse files
authored
Merge pull request #1291 from ClickHouse/gg/append_block_lc_fix
Don't recreate keys from LC columns from direct stream
2 parents 8b2d0a8 + 42eeaa8 commit 6985077

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/column/lowcardinality.go

+3
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ func (col *LowCardinality) Encode(buffer *proto.Buffer) {
220220
}()
221221
ixLen := uint64(len(col.append.index))
222222
switch {
223+
case col.keys().Rows() > 0:
224+
// We already have keys, so this column is probably in a block directly decoded from the server, and we should
225+
// not reset them
223226
case ixLen < math.MaxUint8:
224227
col.key = keyUInt8
225228
for _, v := range col.append.keys {

tests/batch_block_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ func TestBatchAppendRows(t *testing.T) {
4141
// given we have two tables and a million rows in the source table
4242
var tables = []string{"source", "target"}
4343
for _, table := range tables {
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()"))
44+
require.NoError(t, conn.Exec(context.Background(), "create table if not exists "+table+" (number1 Int, number2 LowCardinality(String), number3 Tuple(String, Int), number4 DateTime) engine = Memory()"))
4545
defer conn.Exec(context.Background(), "drop table if exists "+table)
4646
}
4747

48-
require.NoError(t, conn.Exec(ctx, "INSERT INTO source SELECT number, 'string', tuple('foo', number), now() FROM system.numbers LIMIT 1000000"))
48+
require.NoError(t, conn.Exec(ctx, "INSERT INTO source SELECT number, toString(number), tuple('foo', number), now() FROM system.numbers LIMIT 1000000"))
4949

5050
// when we create a batch with direct data block access 10 times
5151
sourceRows, err := conn.Query(ctx, "SELECT * FROM source")

0 commit comments

Comments
 (0)