To give a pseudo-example, it looks like this:
Table table1, ReplicatedMergeTree
a UInt32,
b String
Table table2, ReplicatedMergeTree
a UInt32,
b LowCardinality(String)
INSERT <data> INTO table1
INSERT <data> INTO table2
SELECT * FROM table1
(correct values)
1 x
2 x
3 x
4 y
5 y
6 y
7 z
8 z
SELECT * FROM table1
(incorrect values)
1 x
2 x
3 x
4 y
5 x <= incorrect
6 y
7 z
8 z
I have a hunch (which might be totally wrong, of course) that the mapping for LowCardinality is calculated on all nodes, but since this process is not in sync, it's calculated differently, so during insert, some mapping values are (at least temporarily) different, so the end result will also be different.
Another interesting thing to note is that if we put the SELECT branch into a MATERIALIZED VIEW, then we don't see this behavior - we have the same results for regular String / LowCardinality.
- Csongor