added IColumn::select

This commit is contained in:
Nikolai Kochetov 2018-05-03 15:47:14 +03:00
parent 4ac8078c82
commit 97fbd37cb0
2 changed files with 16 additions and 10 deletions

View File

@ -212,6 +212,8 @@ public:
const IColumn * getIndexes() const { return indexes.get(); } const IColumn * getIndexes() const { return indexes.get(); }
const ColumnPtr & getIndexesPtr() const { return indexes; } const ColumnPtr & getIndexesPtr() const { return indexes; }
void setIndexes(MutableColumnPtr && indexes_) { indexes = indexes_; }
bool withDictionary() const override { return true; } bool withDictionary() const override { return true; }
private: private:

View File

@ -305,19 +305,23 @@ void PreparedFunctionImpl::execute(Block & block, const ColumnNumbers & args, si
executeWithoutColumnsWithDictionary(temp_block, temp_numbers, 0); executeWithoutColumnsWithDictionary(temp_block, temp_numbers, 0);
auto & temp_res_col = temp_block.getByPosition(0).column; auto & temp_res_col = temp_block.getByPosition(0).column;
auto & res_col = block.getByPosition(result); auto & res_col = block.getByPosition(result);
res_col.column = res_col.type->createColumn();
auto * col_with_dict = checkAndGetColumn<ColumnWithDictionary>(res_col.column.get());
if (!col_with_dict)
throw Exception("Expected ColumnWithDictionary, got" + res_col.column->getName(),
ErrorCodes::LOGICAL_ERROR);
ColumnWithDictionary & mut_col_with_dict = col_with_dict->assumeMutableRef();
if (indexes) if (indexes)
res_col.column = ColumnWithDictionary::create(ColumnUnique::create((*std::move(temp_res_col)).mutate(), {
(*std::move(indexes)).mutate())); auto new_ind = mut_col_with_dict.getUnique()->uniqueInsertRangeFrom(*temp_res_col, 0, temp_res_col->size());
mut_col_with_dict.setIndexes(new_ind->index(indexes, 0)->assumeMutable());
}
else else
{ {
res_col.column = res_col.type->createColumn(); mut_col_with_dict.insertRangeFrom(*temp_res_col, 0, temp_res_col->size());
auto * col_with_dict = checkAndGetColumn<ColumnWithDictionary>(res_col.column.get());
if (!col_with_dict)
throw Exception("Expected ColumnWithDictionary, got" + res_col.column->getName(),
ErrorCodes::LOGICAL_ERROR);
col_with_dict->assumeMutableRef().insertRangeFrom(*temp_res_col, 0, temp_res_col->size());
} }
return; return;
} }