Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DYOD] Team 1 - Sprint 4 #2575

Merged
merged 9 commits into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
13 changes: 10 additions & 3 deletions src/test/lib/logical_query_plan/alias_node_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,25 @@ class AliasNodeTest : public BaseTest {
b = mock_node->get_column("b");

aliases = {"x", "y"};
partial_aliases = {"b", "z"};
expressions = {b, a};
alias_node = AliasNode::make(expressions, aliases, mock_node);
partial_alias_node = AliasNode::make(expressions, partial_aliases, mock_node);
}

std::vector<std::string> aliases;
std::vector<std::string> aliases, partial_aliases;
niklasmohrin marked this conversation as resolved.
Show resolved Hide resolved
std::vector<std::shared_ptr<AbstractExpression>> expressions;
std::shared_ptr<MockNode> mock_node;

std::shared_ptr<AbstractExpression> a, b;
std::shared_ptr<AliasNode> alias_node;
std::shared_ptr<AbstractExpression> a, b, c;
std::shared_ptr<AliasNode> alias_node, partial_alias_node;
niklasmohrin marked this conversation as resolved.
Show resolved Hide resolved
};

TEST_F(AliasNodeTest, NodeDescription) {
EXPECT_EQ(alias_node->description(), std::string{"[Alias] b AS x, a AS y"});
EXPECT_EQ(partial_alias_node->description(), std::string{"[Alias] b, a AS z"});
niklasmohrin marked this conversation as resolved.
Show resolved Hide resolved
}

TEST_F(AliasNodeTest, NodeExpressions) {
ASSERT_EQ(alias_node->node_expressions.size(), 2u);
EXPECT_EQ(alias_node->node_expressions.at(0), b);
niklasmohrin marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
29 changes: 28 additions & 1 deletion src/test/lib/logical_query_plan/except_node_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "base_test.hpp"

#include "logical_query_plan/data_dependencies/functional_dependency.hpp"
#include "logical_query_plan/except_node.hpp"
#include "logical_query_plan/lqp_utils.hpp"
#include "logical_query_plan/mock_node.hpp"
Expand All @@ -23,17 +24,43 @@ class ExceptNodeTest : public BaseTest {
_except_node = ExceptNode::make(SetOperationMode::Positions);
_except_node->set_left_input(_mock_node1);
_except_node->set_right_input(_mock_node1);

_except_node_without_right_input = ExceptNode::make(SetOperationMode::Positions);
_except_node_without_right_input->set_left_input(_mock_node1);
}

std::shared_ptr<MockNode> _mock_node1, _mock_node2, _mock_node3;
std::shared_ptr<ExceptNode> _except_node;
std::shared_ptr<ExceptNode> _except_node, _except_node_without_right_input;
niklasmohrin marked this conversation as resolved.
Show resolved Hide resolved
std::shared_ptr<LQPColumnExpression> _a, _b, _c;
};

TEST_F(ExceptNodeTest, Description) {
EXPECT_EQ(_except_node->description(), "[ExceptNode] Mode: Positions");
}

TEST_F(ExceptNodeTest, IsColumnNullable) {
// columns of a MockNode are never nullable
niklasmohrin marked this conversation as resolved.
Show resolved Hide resolved
const auto column_count = _mock_node1->column_definitions().size();
for (auto column_id = ColumnID{0}; column_id < column_count; ++column_id) {
EXPECT_EQ(_except_node->is_column_nullable(column_id), false);
niklasmohrin marked this conversation as resolved.
Show resolved Hide resolved
}

// both left_input and right_input need to be set
EXPECT_THROW(_except_node_without_right_input->is_column_nullable(ColumnID{0}), std::logic_error);
}

TEST_F(ExceptNodeTest, NonTrivialFunctionalDependencies) {
auto fd_a = FunctionalDependency({_a}, {_b, _c});
auto fd_b_two_dependents = FunctionalDependency({_b}, {_a, _c});
niklasmohrin marked this conversation as resolved.
Show resolved Hide resolved

const auto non_trivial_dependencies = FunctionalDependencies{fd_a, fd_b_two_dependents};
_mock_node1->set_non_trivial_functional_dependencies(non_trivial_dependencies);

EXPECT_EQ(_except_node->non_trivial_functional_dependencies(), non_trivial_dependencies);
// Also works if right_input is not set
Bouncner marked this conversation as resolved.
Show resolved Hide resolved
Bouncner marked this conversation as resolved.
Show resolved Hide resolved
EXPECT_EQ(_except_node_without_right_input->non_trivial_functional_dependencies(), non_trivial_dependencies);
}

TEST_F(ExceptNodeTest, OutputColumnExpressions) {
EXPECT_TRUE(_except_node->output_expressions() == _mock_node1->output_expressions());
}
Expand Down
8 changes: 8 additions & 0 deletions src/test/lib/operators/aggregate_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@

namespace hyrise {

class OperatorsAggregateHashTest : public BaseTest {};
dey4ss marked this conversation as resolved.
Show resolved Hide resolved

TEST_F(OperatorsAggregateHashTest, EmptyHash) {
const auto expected_empty_hash = 0;
niklasmohrin marked this conversation as resolved.
Show resolved Hide resolved
EXPECT_EQ(std::hash<EmptyAggregateKey>()(EmptyAggregateKey{}), expected_empty_hash);
EXPECT_EQ(std::hash<AggregateKeySmallVector>()(AggregateKeySmallVector{}), expected_empty_hash);
}

template <typename T>
void test_output(const std::shared_ptr<AbstractOperator> in,
const std::vector<std::pair<ColumnID, AggregateFunction>>& aggregate_definitions,
Expand Down
10 changes: 10 additions & 0 deletions src/test/lib/operators/limit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,14 @@ TEST_F(OperatorsLimitTest, ForwardSortedByFlag) {
}
}

TEST_F(OperatorsLimitTest, OnlyIntegralTypes) {
auto limit = std::make_shared<Limit>(_table_wrapper, to_expression(AllTypeVariant{"test_string"}));
niklasmohrin marked this conversation as resolved.
Show resolved Hide resolved
EXPECT_THROW(limit->execute(), std::logic_error);
}

TEST_F(OperatorsLimitTest, GetName) {
Bouncner marked this conversation as resolved.
Show resolved Hide resolved
dey4ss marked this conversation as resolved.
Show resolved Hide resolved
auto limit = std::make_shared<Limit>(_table_wrapper, to_expression(int64_t{2}));
niklasmohrin marked this conversation as resolved.
Show resolved Hide resolved
EXPECT_EQ(limit->name(), std::string{"Limit"});
}

} // namespace hyrise