Some fixes, more tests

This commit is contained in:
kssenii 2021-08-13 15:07:44 +03:00
parent 55650b1e67
commit 47fb923975
12 changed files with 52 additions and 28 deletions

View File

@ -1032,17 +1032,7 @@ struct AggregateFunctionSingleValueOrNullData : Data
#if USE_EMBEDDED_COMPILER
static constexpr bool is_compilable = Data::is_compilable;
static void compileChangeIfBetter(llvm::IRBuilderBase & builder, llvm::Value * aggregate_data_ptr, llvm::Value * value_to_check)
{
Data::compileChangeFirstTime(builder, aggregate_data_ptr, value_to_check);
}
static void compileChangeIfBetterMerge(llvm::IRBuilderBase & builder, llvm::Value * aggregate_data_dst_ptr, llvm::Value * aggregate_data_src_ptr)
{
Data::compileChangeFirstTimeMerge(builder, aggregate_data_dst_ptr, aggregate_data_src_ptr);
}
static constexpr bool is_compilable = false;
#endif
};

View File

@ -17,6 +17,7 @@ namespace DB
namespace ErrorCodes
{
extern const int INTERSECT_OR_EXCEPT_RESULT_STRUCTURES_MISMATCH;
extern const int LOGICAL_ERROR;
}
static Block getCommonHeader(const Blocks & headers)

View File

@ -36,9 +36,6 @@ void NormalizeSelectWithUnionQueryMatcher::visit(ASTSelectWithUnionQuery & ast,
ASTs selects;
auto & select_list = ast.list_of_selects->children;
if (select_list.size() < 2)
return;
int i;
for (i = union_modes.size() - 1; i >= 0; --i)
{

View File

@ -162,7 +162,7 @@ void SelectIntersectExceptQueryMatcher::visit(ASTSelectWithUnionQuery & ast, Dat
children.emplace_back(std::move(right));
}
ast.union_mode = ASTSelectWithUnionQuery::Mode::ALL;
ast.union_mode = ASTSelectWithUnionQuery::Mode::Unspecified;
ast.list_of_selects->children = std::move(children);
ast.list_of_modes = std::move(modes);
}

View File

@ -32,9 +32,6 @@ ASTPtr ASTSelectWithUnionQuery::clone() const
void ASTSelectWithUnionQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
{
if (!list_of_selects || list_of_selects->children.size() != list_of_modes.size() + 1)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Incorrect ASTSelectWithUnionQuery");
std::string indent_str = settings.one_line ? "" : std::string(4 * frame.indent, ' ');
auto mode_to_str = [&](auto mode)

View File

@ -186,13 +186,13 @@ enum class SubqueryFunctionType
ALL
};
static bool modifyAST(String operator_name, std::shared_ptr<ASTFunction> & function, SubqueryFunctionType type)
static bool modifyAST(const String & operator_name, ASTPtr function, SubqueryFunctionType type)
{
// = ANY --> IN, != ALL --> NOT IN
if ((operator_name == "equals" && type == SubqueryFunctionType::ANY)
|| (operator_name == "notEquals" && type == SubqueryFunctionType::ALL))
if ((type == SubqueryFunctionType::ANY && operator_name == "equals")
|| (type == SubqueryFunctionType::ALL && operator_name == "notEquals"))
{
function->name = "in";
assert_cast<ASTFunction *>(function.get())->name = "in";
if (operator_name == "notEquals")
{
auto function_not = std::make_shared<ASTFunction>();
@ -257,7 +257,7 @@ static bool modifyAST(String operator_name, std::shared_ptr<ASTFunction> & funct
if (operator_name == "equals" || operator_name == "notEquals")
{
aggregate_function->name = "singleValueOrNull";
function->name = "in";
assert_cast<ASTFunction *>(function.get())->name = "in";
if (operator_name == "notEquals")
{
auto function_not = std::make_shared<ASTFunction>();

View File

@ -12,6 +12,11 @@
namespace DB
{
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
}
static Block checkHeaders(const DataStreams & input_streams_)
{
if (input_streams_.empty())

View File

@ -4,11 +4,6 @@
namespace DB
{
namespace ErrorCodes
{
extern const int SET_SIZE_LIMIT_EXCEEDED;
}
IntersectOrExceptTransform::IntersectOrExceptTransform(const Block & header_, Operator operator_)
: IProcessor(InputPorts(2, header_), {header_})
, current_operator(operator_)

View File

@ -66,6 +66,8 @@ select number from numbers(100) intersect select number from numbers(20, 60) exc
57
58
59
select * from (select 1 intersect select 1);
1
with (select number from numbers(10) intersect select 5) as a select a * 10;
50
select count() from (select number from numbers(10) except select 5);
@ -93,3 +95,7 @@ select * from (select 1 union all select 2 union all select 3 union all select 4
2
3
5
select * from (select 1 union all select 2 union all select 3 union all select 4 intersect select 3 union all select 5 except select 1) order by 1;
2
3
5

View File

@ -19,6 +19,7 @@ select 1 intersect select 1 except select 2 intersect select 1 except select 3 i
select number from numbers(10) except select 5;
select number from numbers(100) intersect select number from numbers(20, 60) except select number from numbers(30, 20) except select number from numbers(60, 20);
select * from (select 1 intersect select 1);
with (select number from numbers(10) intersect select 5) as a select a * 10;
select count() from (select number from numbers(10) except select 5);
select count() from (select number from numbers(1000000) intersect select number from numbers(200000, 600000));
@ -30,3 +31,4 @@ select 1 union all select 1 intersect select 1;
select 1 union all select 1 intersect select 2;
select * from (select 1 union all select 2 union all select 3 union all select 4 except select 3 union all select 5) order by 1;
select * from (select 1 union all select 2 union all select 3 union all select 4 intersect select 3 union all select 5) order by 1;
select * from (select 1 union all select 2 union all select 3 union all select 4 intersect select 3 union all select 5 except select 1) order by 1;

View File

@ -0,0 +1,19 @@
-- { echo }
select 1 == any (select number from numbers(10));
1
select 1 == any (select number from numbers(2, 10));
0
select 1 == all (select 1 from numbers(10));
1
select 1 == all (select number from numbers(10));
0
select number as a from numbers(10) where a == any (select number from numbers(3, 3));
3
4
5
-- TODO: Incorrect:
select 1 != any (select 1 from numbers(10));
1
select 1 != all (select 1 from numbers(10));
1
select number as a from numbers(10) where a != any (select number from numbers(3, 3));

View File

@ -0,0 +1,12 @@
-- { echo }
select 1 == any (select number from numbers(10));
select 1 == any (select number from numbers(2, 10));
select 1 == all (select 1 from numbers(10));
select 1 == all (select number from numbers(10));
select number as a from numbers(10) where a == any (select number from numbers(3, 3));
-- TODO: Incorrect:
select 1 != any (select 1 from numbers(10));
select 1 != all (select 1 from numbers(10));
select number as a from numbers(10) where a != any (select number from numbers(3, 3));