提交 7fa5afec 编写于 作者: P philip.han

Support transform_null_in option for StorageSet

上级 c6bf39d7
......@@ -87,10 +87,7 @@ void NO_INLINE Set::insertFromBlockImplCase(
{
if ((*null_map)[i])
{
if (transform_null_in)
{
has_null = true;
}
has_null = true;
if constexpr (build_filter)
{
......@@ -397,7 +394,7 @@ void NO_INLINE Set::executeImplCase(
{
if (has_null_map && (*null_map)[i])
{
if (has_null)
if (transform_null_in && has_null)
vec_res[i] = !negative;
else
vec_res[i] = negative;
......
......@@ -112,7 +112,7 @@ StorageSet::StorageSet(
const ConstraintsDescription & constraints_,
const Context & context_)
: StorageSetOrJoinBase{relative_path_, table_id_, columns_, constraints_, context_},
set(std::make_shared<Set>(SizeLimits(), false, context_.getSettingsRef().transform_null_in))
set(std::make_shared<Set>(SizeLimits(), false, true))
{
Block header = getSampleBlock();
header = header.sortColumns();
......@@ -127,7 +127,7 @@ void StorageSet::finishInsert() { set->finishInsert(); }
size_t StorageSet::getSize() const { return set->getTotalRowCount(); }
void StorageSet::truncate(const ASTPtr &, const Context & context, TableStructureWriteLockHolder &)
void StorageSet::truncate(const ASTPtr &, const Context &, TableStructureWriteLockHolder &)
{
Poco::File(path).remove(true);
Poco::File(path).createDirectories();
......@@ -137,7 +137,7 @@ void StorageSet::truncate(const ASTPtr &, const Context & context, TableStructur
header = header.sortColumns();
increment = 0;
set = std::make_shared<Set>(SizeLimits(), false, context.getSettingsRef().transform_null_in);
set = std::make_shared<Set>(SizeLimits(), false, true);
set->setHeader(header);
}
......
......@@ -62,3 +62,19 @@
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
......@@ -40,8 +40,46 @@ SELECT count() == 3 FROM null_in WHERE i global not in (1, 3);
SELECT count() == 3 FROM null_in WHERE i global not in range(4);
SELECT count() == 3 FROM null_in WHERE s global not in ('1', '3');
DROP TABLE IF EXISTS test_set;
CREATE TABLE test_set (i Nullable(int)) ENGINE = Set();
INSERT INTO test_set VALUES (1), (NULL);
SET transform_null_in = 0;
SELECT count() == 1 FROM null_in WHERE i in test_set;
SELECT count() == 2 FROM null_in WHERE i not in test_set;
SELECT count() == 1 FROM null_in WHERE i global in test_set;
SELECT count() == 2 FROM null_in WHERE i global not in test_set;
SET transform_null_in = 1;
SELECT count() == 3 FROM null_in WHERE i in test_set;
SELECT count() == 2 FROM null_in WHERE i not in test_set;
SELECT count() == 3 FROM null_in WHERE i global in test_set;
SELECT count() == 2 FROM null_in WHERE i global not in test_set;
-- Create with transform_null_in
CREATE TABLE test_set2 (i Nullable(int)) ENGINE = Set();
INSERT INTO test_set2 VALUES (1), (NULL);
SET transform_null_in = 0;
SELECT count() == 1 FROM null_in WHERE i in test_set2;
SELECT count() == 2 FROM null_in WHERE i not in test_set2;
SELECT count() == 1 FROM null_in WHERE i global in test_set2;
SELECT count() == 2 FROM null_in WHERE i global not in test_set2;
SET transform_null_in = 1;
SELECT count() == 3 FROM null_in WHERE i in test_set2;
SELECT count() == 2 FROM null_in WHERE i not in test_set2;
SELECT count() == 3 FROM null_in WHERE i global in test_set2;
SELECT count() == 2 FROM null_in WHERE i global not in test_set2;
DROP TABLE IF EXISTS test_set;
DROP TABLE IF EXISTS null_in;
DROP TABLE IF EXISTS null_in_subquery;
CREATE TABLE null_in_subquery (dt DateTime, idx int, i Nullable(UInt64)) ENGINE = MergeTree() PARTITION BY dt ORDER BY idx;
INSERT INTO null_in_subquery SELECT number % 3, number, number FROM system.numbers LIMIT 99999;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册