mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Support transform_null_in option for StorageSet
This commit is contained in:
parent
c6bf39d7a9
commit
7fa5afecb4
@ -87,10 +87,7 @@ void NO_INLINE Set::insertFromBlockImplCase(
|
|||||||
{
|
{
|
||||||
if ((*null_map)[i])
|
if ((*null_map)[i])
|
||||||
{
|
{
|
||||||
if (transform_null_in)
|
has_null = true;
|
||||||
{
|
|
||||||
has_null = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if constexpr (build_filter)
|
if constexpr (build_filter)
|
||||||
{
|
{
|
||||||
@ -397,7 +394,7 @@ void NO_INLINE Set::executeImplCase(
|
|||||||
{
|
{
|
||||||
if (has_null_map && (*null_map)[i])
|
if (has_null_map && (*null_map)[i])
|
||||||
{
|
{
|
||||||
if (has_null)
|
if (transform_null_in && has_null)
|
||||||
vec_res[i] = !negative;
|
vec_res[i] = !negative;
|
||||||
else
|
else
|
||||||
vec_res[i] = negative;
|
vec_res[i] = negative;
|
||||||
|
@ -112,7 +112,7 @@ StorageSet::StorageSet(
|
|||||||
const ConstraintsDescription & constraints_,
|
const ConstraintsDescription & constraints_,
|
||||||
const Context & context_)
|
const Context & context_)
|
||||||
: StorageSetOrJoinBase{relative_path_, table_id_, columns_, constraints_, 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();
|
Block header = getSampleBlock();
|
||||||
header = header.sortColumns();
|
header = header.sortColumns();
|
||||||
@ -127,7 +127,7 @@ void StorageSet::finishInsert() { set->finishInsert(); }
|
|||||||
size_t StorageSet::getSize() const { return set->getTotalRowCount(); }
|
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).remove(true);
|
||||||
Poco::File(path).createDirectories();
|
Poco::File(path).createDirectories();
|
||||||
@ -137,7 +137,7 @@ void StorageSet::truncate(const ASTPtr &, const Context & context, TableStructur
|
|||||||
header = header.sortColumns();
|
header = header.sortColumns();
|
||||||
|
|
||||||
increment = 0;
|
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);
|
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
|
||||||
|
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 i global not in range(4);
|
||||||
SELECT count() == 3 FROM null_in WHERE s global not in ('1', '3');
|
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;
|
||||||
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS null_in_subquery;
|
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;
|
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;
|
INSERT INTO null_in_subquery SELECT number % 3, number, number FROM system.numbers LIMIT 99999;
|
||||||
|
Loading…
Reference in New Issue
Block a user