Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2102,6 +2102,30 @@ public void testBucketPruning()
}
}

@Test
public void testNullBucket()
{
Session session = getSession();
QueryRunner queryRunner = getQueryRunner();
queryRunner.execute("CREATE TABLE table_with_null_buckets WITH (bucket_count=2, bucketed_by = ARRAY['key']) AS " +
"SELECT 10 x, CAST(NULL AS INTEGER) AS key UNION ALL SELECT 20 x, 1 key");

try {
assertQuery(session, "SELECT COUNT() FROM table_with_null_buckets WHERE key IS NULL", "SELECT 1");
assertQuery(session, "SELECT x FROM table_with_null_buckets WHERE key IS NULL", "SELECT 10");
assertQuery(session, "SELECT key FROM table_with_null_buckets WHERE x = 10", "SELECT NULL");
assertQuery(session, "SELECT x FROM table_with_null_buckets WHERE key = 1", "SELECT 20");
assertQuery(session, "SELECT key FROM table_with_null_buckets WHERE key IS NULL AND x = 10", "SELECT NULL");
assertQuery(session, "SELECT COUNT() FROM table_with_null_buckets WHERE key IS NULL AND x = 1", "SELECT 0");
assertQuery(session, "SELECT COUNT() FROM table_with_null_buckets WHERE key = 10", "SELECT 0");
assertQuery(session, "SELECT COUNT() FROM table_with_null_buckets WHERE key IN (NULL, 1)", "SELECT 1");
assertQuery(session, "SELECT COUNT() FROM table_with_null_buckets WHERE key IS NULL OR key = 1", "SELECT 2");
}
finally {
queryRunner.execute("DROP TABLE table_with_null_buckets");
}
}

@Test
public void testWriteSortedTable()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,14 @@ private static Optional<Set<NullableValue>> extractFixedValueSet(Domain domain)
return Optional.empty();
}

return Optional.of(ranges.stream()
Set<NullableValue> fixedValueSet = ranges.stream()
.map(range -> new NullableValue(domain.getType(), range.getSingleValue()))
.collect(Collectors.toSet()));
.collect(Collectors.toSet());
if (domain.isNullAllowed()) {
fixedValueSet.add(new NullableValue(domain.getType(), null));
}

return Optional.of(fixedValueSet);
}

/**
Expand Down