Unwrap LC column in IExecutablefunction::executeWithoutSparseColumns

This commit is contained in:
Arthur Passos 2022-07-29 12:03:09 -03:00
parent a3c52f1140
commit 59fbd21024
3 changed files with 28 additions and 0 deletions

View File

@ -285,6 +285,8 @@ ColumnPtr IExecutableFunction::executeWithoutSparseColumns(const ColumnsWithType
? res->cloneResized(1)->convertToFullColumnIfConst()
: res;
keys = keys->convertToFullColumnIfLowCardinality();
auto res_mut_dictionary = DataTypeLowCardinality::createColumnUnique(*res_low_cardinality_type->getDictionaryType());
ColumnPtr res_indexes = res_mut_dictionary->uniqueInsertRangeFrom(*keys, 0, keys->size());
ColumnUniquePtr res_dictionary = std::move(res_mut_dictionary);

View File

@ -0,0 +1,26 @@
import pytest
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
node = cluster.add_instance("node")
@pytest.fixture(scope="module", autouse=True)
def start_cluster():
try:
cluster.start()
yield cluster
finally:
cluster.shutdown()
def test_lc_of_string(start_cluster):
result = node.query("WITH ( SELECT toLowCardinality('a') ) AS bar SELECT bar")
assert result == 'a\n'
def test_lc_of_int(start_cluster):
result = node.query("WITH ( SELECT toLowCardinality(1) ) AS bar SELECT bar")
assert result == '1\n'