some methods marked const

This commit is contained in:
2021-12-18 12:21:34 +01:00
parent 40fa78dd2a
commit c9c4f0fba3
8 changed files with 376 additions and 395 deletions

2
.gitignore vendored
View File

@@ -5,3 +5,5 @@ tmp/.idea
Makefile Makefile
localhost.session.sql localhost.session.sql
CMakeFiles CMakeFiles
cmake-build-debug-coverage
.idea

34
index.h
View File

@@ -29,15 +29,15 @@ public:
} }
std::vector<rowid_t> search(ValueNode *key) { std::vector<rowid_t> search(const ValueNode *key) {
return search(to_index_value(key)); return search(to_index_value(key));
} }
void insert(ColValue *key, rowid_t rowid) { void insert(const ColValue *key, rowid_t rowid) {
return insert(to_index_value(key), rowid); return insert(to_index_value(key), rowid);
} }
void remove(ColValue *key, rowid_t rowid) { void remove(const ColValue *key, rowid_t rowid) {
return remove(to_index_value(key), rowid); return remove(to_index_value(key), rowid);
} }
@@ -53,13 +53,9 @@ public:
return m_index_name; return m_index_name;
} }
[[nodiscard]] ColumnType get_data_type() const {
return m_data_type;
}
private: private:
IndexValue to_index_value(const ValueNode *key) {
IndexValue to_index_value(ValueNode *key) {
if (m_data_type == ColumnType::integer_type) if (m_data_type == ColumnType::integer_type)
return key->getIntegerValue(); return key->getIntegerValue();
else if (m_data_type == ColumnType::varchar_type) else if (m_data_type == ColumnType::varchar_type)
@@ -68,16 +64,16 @@ private:
throw Exception("using index on unsupported type"); throw Exception("using index on unsupported type");
} }
IndexValue to_index_value(ColValue *key) { IndexValue to_index_value(const ColValue *key) {
if (m_data_type == ColumnType::integer_type) if (m_data_type == ColumnType::integer_type)
return key->getIntValue(); return key->getIntegerValue();
else if (m_data_type == ColumnType::varchar_type) else if (m_data_type == ColumnType::varchar_type)
return key->getStringValue(); return key->getStringValue();
else else
throw Exception("using index on unsupported type"); throw Exception("using index on unsupported type");
} }
void insert(IndexValue key, rowid_t rowid) { void insert(const IndexValue& key, rowid_t rowid) {
auto search = m_index.find(key); auto search = m_index.find(key);
if (search != m_index.end()) { if (search != m_index.end()) {
if (m_uniq) if (m_uniq)
@@ -92,7 +88,7 @@ private:
} }
} }
void remove(IndexValue key, rowid_t rowid) { void remove(const IndexValue& key, rowid_t rowid) {
auto search = m_index.find(key); auto search = m_index.find(key);
if (search != m_index.end()) { if (search != m_index.end()) {
search->second.erase(find(search->second.begin(), search->second.end(), rowid)); search->second.erase(find(search->second.begin(), search->second.end(), rowid));
@@ -111,21 +107,11 @@ private:
} }
// void dump() {
// std::for_each(m_index.begin(), m_index.end(),
// [](std::pair<IndexValue, std::vector<rowid_t>> element){
// IndexValue key = element.first;
// std::vector<rowid_t> rowids = element.second;
// std::cout << "key: " << key << ", rowids count:" << rowids.size() << std::endl;
// });
// }
private: private:
bool m_uniq; bool m_uniq;
std::string m_index_name; std::string m_index_name;
std::string m_column_name; std::string m_column_name;
ColumnType m_data_type; ColumnType m_data_type;
std::map<IndexValue, std::vector<rowid_t> > m_index; std::map<IndexValue, std::vector<rowid_t> > m_index;
}; };

535
parser.h
View File

@@ -52,41 +52,41 @@ namespace usql {
}; };
struct Node { struct Node {
NodeType node_type; NodeType node_type;
explicit Node(const NodeType type) : node_type(type) {} explicit Node(const NodeType type) : node_type(type) {}
virtual ~Node() = default; virtual ~Node() = default;
virtual void dump() const { virtual void dump() const {
std::cout << "type: Node" << std::endl; std::cout << "type: Node" << std::endl;
} }
}; };
struct ColOrderNode : Node { struct ColOrderNode : Node {
std::string col_name; std::string col_name;
int col_index; int col_index;
bool ascending; bool ascending;
ColOrderNode(std::string name, bool asc) : Node(NodeType::column_order), col_name(std::move(name)), col_index(-1), ascending(asc) {} ColOrderNode(std::string name, bool asc) : Node(NodeType::column_order), col_name(std::move(name)), col_index(-1), ascending(asc) {}
ColOrderNode(int index, bool asc) : Node(NodeType::database_value), col_index(index), ascending(asc) {} ColOrderNode(int index, bool asc) : Node(NodeType::database_value), col_index(index), ascending(asc) {}
void dump() const override { void dump() const override {
std::cout << "type: ColOrderNode, col_name: " << col_name << ", col_index: " << col_index << ", asc: " << ascending << std::endl; std::cout << "type: ColOrderNode, col_name: " << col_name << ", col_index: " << col_index << ", asc: " << ascending << std::endl;
} }
}; };
struct OffsetLimitNode : Node { struct OffsetLimitNode : Node {
int offset; int offset;
int limit; int limit;
OffsetLimitNode(int off, int lim) : Node(NodeType::offset_limit), offset(off), limit(lim) {} OffsetLimitNode(int off, int lim) : Node(NodeType::offset_limit), offset(off), limit(lim) {}
void dump() const override { void dump() const override {
std::cout << "type: OffsetLimitNode, offset: " << offset << ", limit: " << limit << std::endl; std::cout << "type: OffsetLimitNode, offset: " << offset << ", limit: " << limit << std::endl;
} }
}; };
@@ -97,26 +97,26 @@ namespace usql {
SelectColNode(std::unique_ptr<Node> column, std::string alias) : SelectColNode(std::unique_ptr<Node> column, std::string alias) :
Node(NodeType::database_value), value(std::move(column)), name(std::move(alias)) {} Node(NodeType::database_value), value(std::move(column)), name(std::move(alias)) {}
void dump() const override { void dump() const override {
std::cout << "type: SelectColNode, name:" << name << "value:" << std::endl; std::cout << "type: SelectColNode, name:" << name << "value:" << std::endl;
value->dump(); value->dump();
} }
}; };
struct ColDefNode : Node { struct ColDefNode : Node {
std::string name; std::string name;
ColumnType type; ColumnType type;
int order; int order;
int length; int length;
bool null; bool null;
ColDefNode(std::string col_name, ColumnType col_type, int col_order, int col_len, bool nullable) : ColDefNode(std::string col_name, ColumnType col_type, int col_order, int col_len, bool nullable) :
Node(NodeType::column_def), name(std::move(col_name)), type(col_type), order(col_order), length(col_len), Node(NodeType::column_def), name(std::move(col_name)), type(col_type), order(col_order), length(col_len),
null(nullable) {} null(nullable) {}
void dump() const override { void dump() const override {
std::cout << "type: ColDefNode, name: " << name << ", type: " << (int)type << " TODO add more" << std::endl; std::cout << "type: ColDefNode, name: " << name << ", type: " << (int)type << " TODO add more" << std::endl;
} }
}; };
struct FunctionNode : Node { struct FunctionNode : Node {
@@ -126,95 +126,95 @@ namespace usql {
FunctionNode(std::string func_name, std::vector<std::unique_ptr<Node>> pars) : FunctionNode(std::string func_name, std::vector<std::unique_ptr<Node>> pars) :
Node(NodeType::function), function(std::move(func_name)), params(std::move(pars)) {} Node(NodeType::function), function(std::move(func_name)), params(std::move(pars)) {}
void dump() const override { void dump() const override {
std::cout << "type: FunctionNode, function: " << function << " TODO add more" << std::endl; std::cout << "type: FunctionNode, function: " << function << " TODO add more" << std::endl;
} }
}; };
struct TrueNode : Node { struct TrueNode : Node {
TrueNode() : Node(NodeType::true_node) {} TrueNode() : Node(NodeType::true_node) {}
void dump() const override { void dump() const override {
std::cout << "type: TrueNode," << std::endl; std::cout << "type: TrueNode," << std::endl;
} }
}; };
struct ValueNode : Node { struct ValueNode : Node {
explicit ValueNode(NodeType type) : Node(type) {} explicit ValueNode(NodeType type) : Node(type) {}
virtual bool isNull() { return false; } virtual bool isNull() const { return false; }
virtual long getIntegerValue() = 0; virtual long getIntegerValue() const = 0;
virtual double getDoubleValue() = 0; virtual double getDoubleValue() const = 0;
virtual std::string getStringValue() = 0; virtual std::string getStringValue() const = 0;
virtual long getDateValue() = 0; virtual long getDateValue() const = 0;
virtual bool getBooleanValue() = 0; virtual bool getBooleanValue() const = 0;
~ValueNode() override = default; ~ValueNode() override = default;
}; };
struct NullValueNode : ValueNode { struct NullValueNode : ValueNode {
NullValueNode() : ValueNode(NodeType::null_value) {} NullValueNode() : ValueNode(NodeType::null_value) {}
bool isNull() override { return true; } bool isNull() const override { return true; }
long getIntegerValue() override { throw Exception("getIntegerValue not supported on NullValueNode"); }; long getIntegerValue() const override { throw Exception("getIntegerValue not supported on NullValueNode"); };
double getDoubleValue() override { throw Exception("getDoubleValue not supported on NullValueNode"); }; double getDoubleValue() const override { throw Exception("getDoubleValue not supported on NullValueNode"); };
std::string getStringValue() override { throw Exception("getStringValue not supported on NullValueNode"); }; std::string getStringValue() const override { throw Exception("getStringValue not supported on NullValueNode"); };
long getDateValue() override { throw Exception("getDateValue not supported on NullValueNode"); }; long getDateValue() const override { throw Exception("getDateValue not supported on NullValueNode"); };
bool getBooleanValue() override { throw Exception("getBooleanValue not supported on NullValueNode"); }; bool getBooleanValue() const override { throw Exception("getBooleanValue not supported on NullValueNode"); };
void dump() const override { void dump() const override {
std::cout << "type: NullValueNode," << std::endl; std::cout << "type: NullValueNode," << std::endl;
} }
}; };
struct IntValueNode : ValueNode { struct IntValueNode : ValueNode {
long value; long value;
explicit IntValueNode(long value) : ValueNode(NodeType::int_value), value(value) {} explicit IntValueNode(long value) : ValueNode(NodeType::int_value), value(value) {}
long getIntegerValue() override { return value; }; long getIntegerValue() const override { return value; };
double getDoubleValue() override { return (double) value; }; double getDoubleValue() const override { return (double) value; };
std::string getStringValue() override { return Settings::int_to_string(value); } std::string getStringValue() const override { return Settings::int_to_string(value); }
long getDateValue() override { return value; }; long getDateValue() const override { return value; };
bool getBooleanValue() override { return value != 0; }; bool getBooleanValue() const override { return value != 0; };
void dump() const override { void dump() const override {
std::cout << "type: IntValueNode, value: " << value << std::endl; std::cout << "type: IntValueNode, value: " << value << std::endl;
} }
}; };
struct DoubleValueNode : ValueNode { struct DoubleValueNode : ValueNode {
double value; double value;
explicit DoubleValueNode(double value) : ValueNode(NodeType::float_value), value(value) {} explicit DoubleValueNode(double value) : ValueNode(NodeType::float_value), value(value) {}
long getIntegerValue() override { return (long) value; }; long getIntegerValue() const override { return (long) value; };
double getDoubleValue() override { return value; }; double getDoubleValue() const override { return value; };
std::string getStringValue() override { return Settings::double_to_string(value); } std::string getStringValue() const override { return Settings::double_to_string(value); }
long getDateValue() override { return (long) value; }; long getDateValue() const override { return (long) value; };
bool getBooleanValue() override { return value != 0.0; }; bool getBooleanValue() const override { return value != 0.0; };
void dump() const override { void dump() const override {
std::cout << "type: DoubleValueNode, value: " << value << std::endl; std::cout << "type: DoubleValueNode, value: " << value << std::endl;
} }
}; };
struct StringValueNode : ValueNode { struct StringValueNode : ValueNode {
std::string value; std::string value;
explicit StringValueNode(std::string value) : ValueNode(NodeType::string_value), value(std::move(value)) {} explicit StringValueNode(std::string value) : ValueNode(NodeType::string_value), value(std::move(value)) {}
long getIntegerValue() override { return Settings::string_to_int(value); }; long getIntegerValue() const override { return Settings::string_to_int(value); };
double getDoubleValue() override { return Settings::string_to_double(value); }; double getDoubleValue() const override { return Settings::string_to_double(value); };
std::string getStringValue() override { return value; }; std::string getStringValue() const override { return value; };
long getDateValue() override { return Settings::string_to_date(value); }; long getDateValue() const override { return Settings::string_to_date(value); };
bool getBooleanValue() override { return Settings::string_to_bool(value); }; bool getBooleanValue() const override { return Settings::string_to_bool(value); };
void dump() const override { void dump() const override {
std::cout << "type: StringValueNode, value: " << value << std::endl; std::cout << "type: StringValueNode, value: " << value << std::endl;
} }
}; };
struct BooleanValueNode : ValueNode { struct BooleanValueNode : ValueNode {
@@ -222,141 +222,141 @@ namespace usql {
explicit BooleanValueNode(bool value) : ValueNode(NodeType::bool_value), value(value) {} explicit BooleanValueNode(bool value) : ValueNode(NodeType::bool_value), value(value) {}
long getIntegerValue() override { return (long) value; }; long getIntegerValue() const override { return (long) value; };
double getDoubleValue() override { return (double) value; }; double getDoubleValue() const override { return (double) value; };
std::string getStringValue() override { return Settings::bool_to_string(value); } std::string getStringValue() const override { return Settings::bool_to_string(value); }
long getDateValue() override { return (long) value; }; long getDateValue() const override { return (long) value; };
bool getBooleanValue() override { return value; }; bool getBooleanValue() const override { return value; };
void dump() const override { void dump() const override {
std::cout << "type: BooleanValueNode, value: " << value << std::endl; std::cout << "type: BooleanValueNode, value: " << value << std::endl;
} }
}; };
struct DatabaseValueNode : Node { struct DatabaseValueNode : Node {
std::string col_name; std::string col_name;
explicit DatabaseValueNode(std::string name) : Node(NodeType::database_value), col_name(std::move(name)) {} explicit DatabaseValueNode(std::string name) : Node(NodeType::database_value), col_name(std::move(name)) {}
void dump() const override { void dump() const override {
std::cout << "type: DatabaseValueNode, col_name: " << col_name << std::endl; std::cout << "type: DatabaseValueNode, col_name: " << col_name << std::endl;
} }
}; };
enum class LogicalOperatorType { enum class LogicalOperatorType {
and_operator, and_operator,
or_operator or_operator
// not_operator // not_operator
}; };
struct LogicalOperatorNode : Node { struct LogicalOperatorNode : Node {
LogicalOperatorType op; LogicalOperatorType op;
std::unique_ptr<Node> left; std::unique_ptr<Node> left;
std::unique_ptr<Node> right; std::unique_ptr<Node> right;
LogicalOperatorNode(LogicalOperatorType op, std::unique_ptr<Node> left, std::unique_ptr<Node> right) : LogicalOperatorNode(LogicalOperatorType op, std::unique_ptr<Node> left, std::unique_ptr<Node> right) :
Node(NodeType::logical_operator), op(op), left(std::move(left)), right(std::move(right)) {}; Node(NodeType::logical_operator), op(op), left(std::move(left)), right(std::move(right)) {};
void dump() const override { void dump() const override {
std::cout << "type: LogicalOperatorNode, op: " << (int)op << std::endl; std::cout << "type: LogicalOperatorNode, op: " << (int)op << std::endl;
left->dump(); left->dump();
right->dump(); right->dump();
} }
}; };
enum class RelationalOperatorType { enum class RelationalOperatorType {
equal, equal,
greater, greater,
greater_equal, greater_equal,
lesser, lesser,
lesser_equal, lesser_equal,
not_equal, not_equal,
is, is,
is_not is_not
// like // like
}; };
struct RelationalOperatorNode : Node { struct RelationalOperatorNode : Node {
RelationalOperatorType op; RelationalOperatorType op;
std::unique_ptr<Node> left; std::unique_ptr<Node> left;
std::unique_ptr<Node> right; std::unique_ptr<Node> right;
RelationalOperatorNode(RelationalOperatorType op, std::unique_ptr<Node> left, std::unique_ptr<Node> right) : RelationalOperatorNode(RelationalOperatorType op, std::unique_ptr<Node> left, std::unique_ptr<Node> right) :
Node(NodeType::relational_operator), op(op), left(std::move(left)), right(std::move(right)) {}; Node(NodeType::relational_operator), op(op), left(std::move(left)), right(std::move(right)) {};
void dump() const override { void dump() const override {
std::cout << "type: RelationalOperatorNode, op: " << (int)op << std::endl; std::cout << "type: RelationalOperatorNode, op: " << (int)op << std::endl;
left->dump(); left->dump();
right->dump(); right->dump();
} }
}; };
enum class ArithmeticalOperatorType { enum class ArithmeticalOperatorType {
copy_value, // just copy lef value and do nothing with it copy_value, // just copy lef value and do nothing with it
plus_operator, plus_operator,
minus_operator, minus_operator,
multiply_operator, multiply_operator,
divide_operator divide_operator
}; };
struct ArithmeticalOperatorNode : Node { struct ArithmeticalOperatorNode : Node {
ArithmeticalOperatorType op; ArithmeticalOperatorType op;
std::unique_ptr<Node> left; std::unique_ptr<Node> left;
std::unique_ptr<Node> right; std::unique_ptr<Node> right;
ArithmeticalOperatorNode(ArithmeticalOperatorType op, std::unique_ptr<Node> left, std::unique_ptr<Node> right) : ArithmeticalOperatorNode(ArithmeticalOperatorType op, std::unique_ptr<Node> left, std::unique_ptr<Node> right) :
Node(NodeType::arithmetical_operator), op(op), left(std::move(left)), right(std::move(right)) {}; Node(NodeType::arithmetical_operator), op(op), left(std::move(left)), right(std::move(right)) {};
void dump() const override { void dump() const override {
std::cout << "type: ArithmeticalOperatorNode, op: " << (int)op << std::endl; std::cout << "type: ArithmeticalOperatorNode, op: " << (int)op << std::endl;
left->dump(); left->dump();
right->dump(); right->dump();
} }
}; };
struct CreateTableNode : Node { struct CreateTableNode : Node {
std::string table_name; std::string table_name;
std::vector<ColDefNode> cols_defs; std::vector<ColDefNode> cols_defs;
CreateTableNode(std::string name, std::vector<ColDefNode> defs) : CreateTableNode(std::string name, std::vector<ColDefNode> defs) :
Node(NodeType::create_table), table_name(std::move(name)), cols_defs(std::move(defs)) {} Node(NodeType::create_table), table_name(std::move(name)), cols_defs(std::move(defs)) {}
void dump() const override { void dump() const override {
std::cout << "type: CreateTableNode, table_name: " << table_name << "TODO complete me" << std::endl; std::cout << "type: CreateTableNode, table_name: " << table_name << "TODO complete me" << std::endl;
} }
}; };
struct InsertIntoTableNode : Node { struct InsertIntoTableNode : Node {
std::string table_name; std::string table_name;
std::vector<DatabaseValueNode> cols_names; std::vector<DatabaseValueNode> cols_names;
std::vector<std::unique_ptr<Node>> cols_values; std::vector<std::unique_ptr<Node>> cols_values;
InsertIntoTableNode(std::string name, std::vector<DatabaseValueNode> names, std::vector<std::unique_ptr<Node>> values) : InsertIntoTableNode(std::string name, std::vector<DatabaseValueNode> names, std::vector<std::unique_ptr<Node>> values) :
Node(NodeType::insert_into), table_name(std::move(name)), cols_names(std::move(names)), cols_values(std::move(values)) {} Node(NodeType::insert_into), table_name(std::move(name)), cols_names(std::move(names)), cols_values(std::move(values)) {}
void dump() const override { void dump() const override {
std::cout << "type: InsertIntoTableNode, table_name: " << table_name << "TODO complete me" << std::endl; std::cout << "type: InsertIntoTableNode, table_name: " << table_name << "TODO complete me" << std::endl;
} }
}; };
struct SelectFromTableNode : Node { struct SelectFromTableNode : Node {
std::string table_name; std::string table_name;
std::unique_ptr<std::vector<SelectColNode>> cols_names; std::unique_ptr<std::vector<SelectColNode>> cols_names;
std::unique_ptr<Node> where; std::unique_ptr<Node> where;
std::vector<ColOrderNode> order_by; std::vector<ColOrderNode> order_by;
OffsetLimitNode offset_limit; OffsetLimitNode offset_limit;
bool distinct; bool distinct;
SelectFromTableNode(std::string name, std::unique_ptr<std::vector<SelectColNode>> names, std::unique_ptr<Node> where_clause, std::vector<ColOrderNode> orderby, OffsetLimitNode offlim, bool distinct_): SelectFromTableNode(std::string name, std::unique_ptr<std::vector<SelectColNode>> names, std::unique_ptr<Node> where_clause, std::vector<ColOrderNode> orderby, OffsetLimitNode offlim, bool distinct_):
Node(NodeType::select_from), table_name(std::move(name)), cols_names(std::move(names)), where(std::move(where_clause)), order_by(std::move(orderby)), offset_limit(std::move(offlim)), distinct(distinct_) {} Node(NodeType::select_from), table_name(std::move(name)), cols_names(std::move(names)), where(std::move(where_clause)), order_by(std::move(orderby)), offset_limit(std::move(offlim)), distinct(distinct_) {}
void dump() const override { void dump() const override {
std::cout << "type: SelectFromTableNode, table_name: " << table_name << "TODO complete me" << std::endl; std::cout << "type: SelectFromTableNode, table_name: " << table_name << "TODO complete me" << std::endl;
where->dump(); where->dump();
} }
}; };
struct CreateTableAsSelectNode : Node { struct CreateTableAsSelectNode : Node {
@@ -366,51 +366,51 @@ namespace usql {
CreateTableAsSelectNode(std::string name, std::unique_ptr<Node> table) : CreateTableAsSelectNode(std::string name, std::unique_ptr<Node> table) :
Node(NodeType::create_table_as_select), table_name(std::move(name)), select_table(std::move(table)) {} Node(NodeType::create_table_as_select), table_name(std::move(name)), select_table(std::move(table)) {}
void dump() const override { void dump() const override {
std::cout << "type: CreateTableAsSelectNode, table_name: " << table_name << std::endl; std::cout << "type: CreateTableAsSelectNode, table_name: " << table_name << std::endl;
select_table->dump(); select_table->dump();
} }
}; };
struct UpdateTableNode : Node { struct UpdateTableNode : Node {
std::string table_name; std::string table_name;
std::vector<DatabaseValueNode> cols_names; std::vector<DatabaseValueNode> cols_names;
std::vector<std::unique_ptr<Node>> values; std::vector<std::unique_ptr<Node>> values;
std::unique_ptr<Node> where; std::unique_ptr<Node> where;
UpdateTableNode(std::string name, std::vector<DatabaseValueNode> names, std::vector<std::unique_ptr<Node>> vals, UpdateTableNode(std::string name, std::vector<DatabaseValueNode> names, std::vector<std::unique_ptr<Node>> vals,
std::unique_ptr<Node> where_clause) : std::unique_ptr<Node> where_clause) :
Node(NodeType::update_table), table_name(std::move(name)), cols_names(std::move(names)), values(std::move(vals)), Node(NodeType::update_table), table_name(std::move(name)), cols_names(std::move(names)), values(std::move(vals)),
where(std::move(where_clause)) {} where(std::move(where_clause)) {}
void dump() const override { void dump() const override {
std::cout << "type: UpdateTableNode, table_name: " << table_name << "TODO complete me" << std::endl; std::cout << "type: UpdateTableNode, table_name: " << table_name << "TODO complete me" << std::endl;
where->dump(); where->dump();
} }
}; };
struct LoadIntoTableNode : Node { struct LoadIntoTableNode : Node {
std::string table_name; std::string table_name;
std::string filename; std::string filename;
LoadIntoTableNode(std::string name, std::string file) : LoadIntoTableNode(std::string name, std::string file) :
Node(NodeType::load_table), table_name(std::move(name)), filename(std::move(file)) {} Node(NodeType::load_table), table_name(std::move(name)), filename(std::move(file)) {}
void dump() const override { void dump() const override {
std::cout << "type: LoadIntoTableNode, table_name: " << table_name << ", filename" << filename << std::endl; std::cout << "type: LoadIntoTableNode, table_name: " << table_name << ", filename" << filename << std::endl;
} }
}; };
struct SaveTableNode : Node { struct SaveTableNode : Node {
std::string table_name; std::string table_name;
std::string filename; std::string filename;
SaveTableNode(std::string name, std::string file) : SaveTableNode(std::string name, std::string file) :
Node(NodeType::save_table), table_name(std::move(name)), filename(std::move(file)) {} Node(NodeType::save_table), table_name(std::move(name)), filename(std::move(file)) {}
void dump() const override { void dump() const override {
std::cout << "type: SaveTableNode, table_name: " << table_name << ", filename" << filename << std::endl; std::cout << "type: SaveTableNode, table_name: " << table_name << ", filename" << filename << std::endl;
} }
}; };
struct DropTableNode : Node { struct DropTableNode : Node {
@@ -418,95 +418,94 @@ namespace usql {
explicit DropTableNode(std::string name) : Node(NodeType::drop_table), table_name(std::move(name)) {} explicit DropTableNode(std::string name) : Node(NodeType::drop_table), table_name(std::move(name)) {}
void dump() const override { void dump() const override {
std::cout << "type: SelectFromTableNode, table_name: " << table_name << std::endl; std::cout << "type: SelectFromTableNode, table_name: " << table_name << std::endl;
} }
}; };
struct DeleteFromTableNode : Node { struct DeleteFromTableNode : Node {
std::string table_name; std::string table_name;
std::unique_ptr<Node> where; std::unique_ptr<Node> where;
DeleteFromTableNode(std::string name, std::unique_ptr<Node> where_clause) : DeleteFromTableNode(std::string name, std::unique_ptr<Node> where_clause) :
Node(NodeType::delete_from), table_name(std::move(name)), where(std::move(where_clause)) {} Node(NodeType::delete_from), table_name(std::move(name)), where(std::move(where_clause)) {}
void dump() const override { void dump() const override {
std::cout << "type: DeleteFromTableNode, table_name: " << table_name << std::endl; std::cout << "type: DeleteFromTableNode, table_name: " << table_name << std::endl;
where->dump(); where->dump();
} }
}; };
struct SetNode : Node { struct SetNode : Node {
std::string name; std::string name;
std::string value; std::string value;
SetNode(std::string node_name, std::string node_value) : SetNode(std::string node_name, std::string node_value) :
Node(NodeType::set), name(std::move(node_name)), value(std::move(node_value)) {} Node(NodeType::set), name(std::move(node_name)), value(std::move(node_value)) {}
void dump() const override { void dump() const override {
std::cout << "type: SetNode, name: " << name << ", value: " << value << std::endl; std::cout << "type: SetNode, name: " << name << ", value: " << value << std::endl;
} }
}; };
struct ShowNode : Node { struct ShowNode : Node {
std::string name; std::string name;
explicit ShowNode(std::string node_name) : Node(NodeType::show), name(std::move(node_name)) {} explicit ShowNode(std::string node_name) : Node(NodeType::show), name(std::move(node_name)) {}
void dump() const override { void dump() const override {
std::cout << "type: ShowNode, name: " << name << std::endl; std::cout << "type: ShowNode, name: " << name << std::endl;
} }
}; };
struct CreateIndexNode : Node { struct CreateIndexNode : Node {
std::string index_name; std::string index_name;
std::string table_name; std::string table_name;
std::string column_name; std::string column_name;
CreateIndexNode(std::string idx_name, std::string tbl_name, std::string col_name) : CreateIndexNode(std::string idx_name, std::string tbl_name, std::string col_name) :
Node(NodeType::create_index), index_name(std::move(idx_name)), table_name(std::move(tbl_name)), column_name(std::move(col_name)) {} Node(NodeType::create_index), index_name(std::move(idx_name)), table_name(std::move(tbl_name)), column_name(std::move(col_name)) {}
void dump() const override { void dump() const override {
std::cout << "type: CreateIndexNode, table_name: " << table_name << ", index_name: " << index_name << ", column_name: " << column_name << std::endl; std::cout << "type: CreateIndexNode, table_name: " << table_name << ", index_name: " << index_name << ", column_name: " << column_name << std::endl;
} }
}; };
class Parser { class Parser {
private: private:
public:
Parser();
public: std::unique_ptr<Node> parse(const std::string &code);
Parser();
std::unique_ptr<Node> parse(const std::string &code); private:
std::unique_ptr<Node> parse_create_table();
std::unique_ptr<Node> parse_drop_table();
std::unique_ptr<Node> parse_load_table();
std::unique_ptr<Node> parse_save_table();
std::unique_ptr<Node> parse_set();
std::unique_ptr<Node> parse_show();
private: std::unique_ptr<Node> parse_insert_into_table();
std::unique_ptr<Node> parse_create_table(); std::unique_ptr<Node> parse_select_from_table();
std::unique_ptr<Node> parse_drop_table(); std::unique_ptr<Node> parse_delete_from_table();
std::unique_ptr<Node> parse_load_table(); std::unique_ptr<Node> parse_update_table();
std::unique_ptr<Node> parse_save_table(); std::unique_ptr<Node> parse_create_index();
std::unique_ptr<Node> parse_set();
std::unique_ptr<Node> parse_show();
std::unique_ptr<Node> parse_insert_into_table(); std::vector<ColOrderNode> parse_order_by_clause();
std::unique_ptr<Node> parse_select_from_table(); OffsetLimitNode parse_offset_limit_clause();
std::unique_ptr<Node> parse_delete_from_table();
std::unique_ptr<Node> parse_update_table();
std::unique_ptr<Node> parse_create_index();
std::vector<ColOrderNode> parse_order_by_clause(); std::unique_ptr<Node> parse_where_clause();
OffsetLimitNode parse_offset_limit_clause(); std::unique_ptr<Node> parse_expression();
std::unique_ptr<Node> parse_expression(std::unique_ptr<Node> left);
std::unique_ptr<Node> parse_where_clause(); std::unique_ptr<Node> parse_value();
std::unique_ptr<Node> parse_expression(); RelationalOperatorType parse_relational_operator();
std::unique_ptr<Node> parse_expression(std::unique_ptr<Node> left); LogicalOperatorType parse_logical_operator();
ArithmeticalOperatorType parse_arithmetical_operator();
std::unique_ptr<Node> parse_value(); private:
RelationalOperatorType parse_relational_operator(); Lexer m_lexer;
LogicalOperatorType parse_logical_operator(); };
ArithmeticalOperatorType parse_arithmetical_operator();
private:
Lexer m_lexer;
};
} // namespace } // namespace

20
row.cpp
View File

@@ -4,16 +4,16 @@
namespace usql { namespace usql {
int ColNullValue::compare(ColValue &other) { int ColNullValue::compare(ColValue &other) const {
return other.isNull() ? 0 : -1; // null goes to end return other.isNull() ? 0 : -1; // null goes to end
} }
int ColIntegerValue::compare(ColValue &other) { int ColIntegerValue::compare(ColValue &other) const {
long r = m_integer - other.getIntValue(); long r = m_integer - other.getIntegerValue();
return other.isNull() ? 1 : r > 0 ? 1 : r == 0 ? 0 : -1; return other.isNull() ? 1 : r > 0 ? 1 : r == 0 ? 0 : -1;
} }
int ColDoubleValue::compare(ColValue &other) { int ColDoubleValue::compare(ColValue &other) const {
if (other.isNull()) return 1; // null goes to end if (other.isNull()) return 1; // null goes to end
double c = m_double - other.getDoubleValue(); double c = m_double - other.getDoubleValue();
@@ -25,16 +25,16 @@ ColStringValue & ColStringValue::operator=(ColStringValue other) {
return *this; return *this;
} }
int ColStringValue::compare(ColValue &other) { int ColStringValue::compare(ColValue &other) const {
return other.isNull() ? 1 : m_string->compare(other.getStringValue()); // null goes to end return other.isNull() ? 1 : m_string->compare(other.getStringValue()); // null goes to end
} }
int ColDateValue::compare(ColValue &other) { int ColDateValue::compare(ColValue &other) const {
long r = m_date - other.getIntValue(); long r = m_date - other.getIntegerValue();
return other.isNull() ? 1 : r > 0 ? 1 : r == 0 ? 0 : -1; return other.isNull() ? 1 : r > 0 ? 1 : r == 0 ? 0 : -1;
} }
int ColBooleanValue::compare(ColValue &other) { int ColBooleanValue::compare(ColValue &other) const {
if (other.isNull()) return 1; // null goes to end if (other.isNull()) return 1; // null goes to end
return m_bool == other.getBoolValue() ? 0 : m_bool && !other.getBoolValue() ? -1 : 1; // true first return m_bool == other.getBoolValue() ? 0 : m_bool && !other.getBoolValue() ? -1 : 1; // true first
@@ -48,7 +48,7 @@ Row::Row(const Row &other) : m_columns(other.m_columns.size()), m_visible(other.
ColumnType col_type = other[i].getColType(); ColumnType col_type = other[i].getColType();
switch (col_type) { switch (col_type) {
case ColumnType::integer_type : case ColumnType::integer_type :
setIntColumnValue(i, other[i].getIntValue()); setIntColumnValue(i, other[i].getIntegerValue());
break; break;
case ColumnType::float_type : case ColumnType::float_type :
setFloatColumnValue(i, other[i].getDoubleValue()); setFloatColumnValue(i, other[i].getDoubleValue());
@@ -110,7 +110,7 @@ void Row::setBoolColumnValue(int col_index, const std::string &value) {
void Row::setColumnValue(ColDefNode *col_def, ColValue &col_value) { void Row::setColumnValue(ColDefNode *col_def, ColValue &col_value) {
if (!col_value.isNull()) { if (!col_value.isNull()) {
if (col_def->type == ColumnType::integer_type) if (col_def->type == ColumnType::integer_type)
setIntColumnValue(col_def->order, col_value.getIntValue()); setIntColumnValue(col_def->order, col_value.getIntegerValue());
else if (col_def->type == ColumnType::float_type) else if (col_def->type == ColumnType::float_type)
setFloatColumnValue(col_def->order, col_value.getDoubleValue()); setFloatColumnValue(col_def->order, col_value.getDoubleValue());
else if (col_def->type == ColumnType::varchar_type) else if (col_def->type == ColumnType::varchar_type)

159
row.h
View File

@@ -9,135 +9,134 @@
namespace usql { namespace usql {
struct ColValue { struct ColValue {
virtual bool isNull() { return false; }; virtual bool isNull() const { return false; };
virtual ColumnType getColType() = 0; virtual ColumnType getColType() const = 0;
virtual long getIntValue() = 0; virtual long getIntegerValue() const = 0;
virtual double getDoubleValue() = 0; virtual double getDoubleValue() const = 0;
virtual std::string getStringValue() = 0; virtual std::string getStringValue() const = 0;
virtual long getDateValue() = 0; virtual long getDateValue() const = 0;
virtual bool getBoolValue() = 0; virtual bool getBoolValue() const = 0;
virtual int compare(ColValue &other) = 0; virtual int compare(ColValue &other) const = 0;
virtual ~ColValue() = default; virtual ~ColValue() = default;
};
};
struct ColNullValue : ColValue { struct ColNullValue : ColValue {
bool isNull() override { return true; }; bool isNull() const override { return true; };
ColumnType getColType() override { throw Exception("getColType not supported on ColNullValue"); } ColumnType getColType() const override { throw Exception("getColType not supported on ColNullValue"); }
long getIntValue() override { throw Exception("getIntValue not supported on ColNullValue"); }; long getIntegerValue() const override { throw Exception("getIntegerValue not supported on ColNullValue"); };
double getDoubleValue() override { throw Exception("getDoubleValue not supported on ColNullValue"); }; double getDoubleValue() const override { throw Exception("getDoubleValue not supported on ColNullValue"); };
std::string getStringValue() override { return "null"; }; std::string getStringValue() const override { return "null"; };
long getDateValue() override { throw Exception("getDateValue not supported on ColNullValue"); }; long getDateValue() const override { throw Exception("getDateValue not supported on ColNullValue"); };
bool getBoolValue() override { throw Exception("getDateValue not supported on ColNullValue"); }; bool getBoolValue() const override { throw Exception("getDateValue not supported on ColNullValue"); };
int compare(ColValue &other) override; int compare(ColValue &other) const override;
~ColNullValue() override = default; ~ColNullValue() override = default;
}; };
struct ColIntegerValue : ColValue { struct ColIntegerValue : ColValue {
explicit ColIntegerValue(long value) : m_integer(value) {}; explicit ColIntegerValue(long value) : m_integer(value) {};
ColIntegerValue(const ColIntegerValue &other) : m_integer(other.m_integer) {}; ColIntegerValue(const ColIntegerValue &other) : m_integer(other.m_integer) {};
ColumnType getColType() override { return ColumnType::integer_type; }; ColumnType getColType() const override { return ColumnType::integer_type; };
long getIntValue() override { return m_integer; }; long getIntegerValue() const override { return m_integer; };
double getDoubleValue() override { return (double) m_integer; }; double getDoubleValue() const override { return (double) m_integer; };
std::string getStringValue() override { return std::to_string(m_integer); }; std::string getStringValue() const override { return std::to_string(m_integer); };
long getDateValue() override { return m_integer; }; long getDateValue() const override { return m_integer; };
bool getBoolValue() override { throw Exception("Not supported on ColIntegerValue"); }; bool getBoolValue() const override { throw Exception("Not supported on ColIntegerValue"); };
int compare(ColValue &other) override; int compare(ColValue &other) const override;
long m_integer;
~ColIntegerValue() override = default; ~ColIntegerValue() override = default;
};
long m_integer;
};
struct ColDoubleValue : ColValue { struct ColDoubleValue : ColValue {
explicit ColDoubleValue(double value) : m_double(value) {}; explicit ColDoubleValue(double value) : m_double(value) {};
ColDoubleValue(const ColDoubleValue &other) : m_double(other.m_double) {} ColDoubleValue(const ColDoubleValue &other) : m_double(other.m_double) {}
ColumnType getColType() override { return ColumnType::float_type; }; ColumnType getColType() const override { return ColumnType::float_type; };
long getIntValue() override { return (long) m_double; }; long getIntegerValue() const override { return (long) m_double; };
double getDoubleValue() override { return m_double; }; double getDoubleValue() const override { return m_double; };
std::string getStringValue() override { return Settings::double_to_string(m_double); }; std::string getStringValue() const override { return Settings::double_to_string(m_double); };
long getDateValue() override { return (long) m_double; }; long getDateValue() const override { return (long) m_double; };
bool getBoolValue() override { throw Exception("Not supported on ColDoubleValue"); }; bool getBoolValue() const override { throw Exception("Not supported on ColDoubleValue"); };
int compare(ColValue &other) override; int compare(ColValue &other) const override;
~ColDoubleValue() override = default; ~ColDoubleValue() override = default;
double m_double; double m_double;
}; };
struct ColStringValue : ColValue { struct ColStringValue : ColValue {
explicit ColStringValue(const std::string &value) : m_string(std::make_unique<std::string>(value)) {}; explicit ColStringValue(const std::string &value) : m_string(std::make_unique<std::string>(value)) {};
ColStringValue(const ColStringValue &other) : m_string(std::make_unique<std::string>(*other.m_string)) {}; ColStringValue(const ColStringValue &other) : m_string(std::make_unique<std::string>(*other.m_string)) {};
ColStringValue & operator=(ColStringValue other); ColStringValue & operator=(ColStringValue other);
ColumnType getColType() override { return ColumnType::varchar_type; }; ColumnType getColType() const override { return ColumnType::varchar_type; };
long getIntValue() override { return std::stoi(*m_string); }; long getIntegerValue() const override { return std::stoi(*m_string); };
double getDoubleValue() override { return std::stod(*m_string); }; double getDoubleValue() const override { return std::stod(*m_string); };
std::string getStringValue() override { return *m_string; }; std::string getStringValue() const override { return *m_string; };
long getDateValue() override { return std::stoi(*m_string); }; long getDateValue() const override { return std::stoi(*m_string); };
bool getBoolValue() override { throw Exception("Not supported on ColStringValue"); }; bool getBoolValue() const override { throw Exception("Not supported on ColStringValue"); };
int compare(ColValue &other) override; int compare(ColValue &other) const override;
std::unique_ptr<std::string> m_string; std::unique_ptr<std::string> m_string;
}; };
struct ColDateValue : ColValue { struct ColDateValue : ColValue {
explicit ColDateValue(long value) : m_date(value) {}; explicit ColDateValue(long value) : m_date(value) {};
ColDateValue(const ColDateValue &other) : m_date(other.m_date) {}; ColDateValue(const ColDateValue &other) : m_date(other.m_date) {};
ColumnType getColType() override { return ColumnType::date_type; }; ColumnType getColType() const override { return ColumnType::date_type; };
long getIntValue() override { return m_date; }; long getIntegerValue() const override { return m_date; };
double getDoubleValue() override { return (double) m_date; }; double getDoubleValue() const override { return (double) m_date; };
std::string getStringValue() override { return Settings::date_to_string(m_date); }; std::string getStringValue() const override { return Settings::date_to_string(m_date); };
long getDateValue() override { return m_date; }; long getDateValue() const override { return m_date; };
bool getBoolValue() override { throw Exception("Not supported on ColDateValue"); }; bool getBoolValue() const override { throw Exception("Not supported on ColDateValue"); };
int compare(ColValue &other) override; int compare(ColValue &other) const override;
~ColDateValue() override = default; ~ColDateValue() override = default;
long m_date; // seconds since epoch for now long m_date; // seconds since epoch for now
}; };
struct ColBooleanValue : ColValue { struct ColBooleanValue : ColValue {
explicit ColBooleanValue(bool value) : m_bool(value) {}; explicit ColBooleanValue(bool value) : m_bool(value) {};
ColBooleanValue(const ColBooleanValue &other) : m_bool(other.m_bool) {}; ColBooleanValue(const ColBooleanValue &other) : m_bool(other.m_bool) {};
ColumnType getColType() override { return ColumnType::bool_type; }; ColumnType getColType() const override { return ColumnType::bool_type; };
long getIntValue() override { return (long) m_bool; }; long getIntegerValue() const override { return (long) m_bool; };
double getDoubleValue() override { return (double) m_bool; }; double getDoubleValue() const override { return (double) m_bool; };
std::string getStringValue() override { return m_bool ? "Y" : "N"; }; std::string getStringValue() const override { return m_bool ? "Y" : "N"; };
long getDateValue() override { throw Exception("Not supported on ColBooleanValue"); }; long getDateValue() const override { throw Exception("Not supported on ColBooleanValue"); };
bool getBoolValue() override { return m_bool; }; bool getBoolValue() const override { return m_bool; };
int compare(ColValue &other) override; int compare(ColValue &other) const override;
~ColBooleanValue() override = default; ~ColBooleanValue() override = default;
bool m_bool; bool m_bool;
}; };
class Row { class Row {
public: public:
explicit Row(int cols_count, bool visible) : m_columns(cols_count), m_visible(visible) {}; explicit Row(int cols_count, bool visible) : m_columns(cols_count), m_visible(visible) {};
Row(const Row &other); Row(const Row &other);
Row &operator=(Row other); Row &operator=(Row other);
@@ -154,7 +153,7 @@ namespace usql {
void setColumnValue(ColDefNode *col_def, ColValue &col_value); void setColumnValue(ColDefNode *col_def, ColValue &col_value);
void setColumnValue(ColDefNode *col_def, ValueNode *col_value); void setColumnValue(ColDefNode *col_def, ValueNode *col_value);
ColValue &operator[](int i) const { ColValue &operator[](int i) const {
auto type_index = m_columns[i].index(); auto type_index = m_columns[i].index();
switch (type_index) { switch (type_index) {
case 0: case 0:
@@ -183,9 +182,9 @@ namespace usql {
void set_visible() { m_visible = true; }; void set_visible() { m_visible = true; };
void set_deleted() { m_visible = true; }; void set_deleted() { m_visible = true; };
private: private:
bool m_visible; bool m_visible;
std::vector<std::variant<ColNullValue, ColIntegerValue, ColDoubleValue, ColStringValue, ColDateValue, ColBooleanValue>> m_columns; std::vector<std::variant<ColNullValue, ColIntegerValue, ColDoubleValue, ColStringValue, ColDateValue, ColBooleanValue>> m_columns;
}; };
} // namespace } // namespace

View File

@@ -217,7 +217,7 @@ void Table::commit_copy_of_row(Row &row) {
new_row.setColumnNull(i); new_row.setColumnNull(i);
} else { } else {
if (m_col_defs[i].type == ColumnType::integer_type) { if (m_col_defs[i].type == ColumnType::integer_type) {
new_row.setIntColumnValue(i, row[i].getIntValue()); new_row.setIntColumnValue(i, row[i].getIntegerValue());
} else if (m_col_defs[i].type == ColumnType::float_type) { } else if (m_col_defs[i].type == ColumnType::float_type) {
new_row.setFloatColumnValue(i, row[i].getDoubleValue()); new_row.setFloatColumnValue(i, row[i].getDoubleValue());
} else if (m_col_defs[i].type == ColumnType::varchar_type) { } else if (m_col_defs[i].type == ColumnType::varchar_type) {

View File

@@ -7,17 +7,12 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <iterator> // For std::forward_iterator_tag
#include <cstddef> // For std::ptrdiff_t
namespace usql { namespace usql {
//using IndexValue=std::variant<ColNullValue, ColIntegerValue, ColStringValue>;
using IndexValue=std::variant<long, std::string>; using IndexValue=std::variant<long, std::string>;
struct Table { struct Table {
Table(const Table &other); Table(const Table &other);
Table(const std::string& name, const std::vector<ColDefNode>& columns); Table(const std::string& name, const std::vector<ColDefNode>& columns);

View File

@@ -130,7 +130,7 @@ std::unique_ptr<ValueNode> USql::eval_database_value_node(Table *table, Row &row
return std::make_unique<NullValueNode>(); return std::make_unique<NullValueNode>();
if (col_def.type == ColumnType::integer_type) if (col_def.type == ColumnType::integer_type)
return std::make_unique<IntValueNode>(db_value.getIntValue()); return std::make_unique<IntValueNode>(db_value.getIntegerValue());
if (col_def.type == ColumnType::float_type) if (col_def.type == ColumnType::float_type)
return std::make_unique<DoubleValueNode>(db_value.getDoubleValue()); return std::make_unique<DoubleValueNode>(db_value.getDoubleValue());
if (col_def.type == ColumnType::varchar_type) if (col_def.type == ColumnType::varchar_type)
@@ -138,7 +138,7 @@ std::unique_ptr<ValueNode> USql::eval_database_value_node(Table *table, Row &row
if (col_def.type == ColumnType::bool_type) if (col_def.type == ColumnType::bool_type)
return std::make_unique<BooleanValueNode>(db_value.getBoolValue()); return std::make_unique<BooleanValueNode>(db_value.getBoolValue());
if (col_def.type == ColumnType::date_type) if (col_def.type == ColumnType::date_type)
return std::make_unique<IntValueNode>(db_value.getIntValue()); return std::make_unique<IntValueNode>(db_value.getIntegerValue());
throw Exception("unknown database value type"); throw Exception("unknown database value type");
} }
@@ -197,7 +197,7 @@ USql::eval_function_value_node(Table *table, Row &row, Node *node, ColDefNode *c
std::unique_ptr<ValueNode> USql::count_function(ColValue *agg_func_value, const std::vector<std::unique_ptr<ValueNode>> &evaluatedPars) { std::unique_ptr<ValueNode> USql::count_function(ColValue *agg_func_value, const std::vector<std::unique_ptr<ValueNode>> &evaluatedPars) {
long c = 1; long c = 1;
if (!agg_func_value->isNull()) { if (!agg_func_value->isNull()) {
c = agg_func_value->getIntValue() + 1; c = agg_func_value->getIntegerValue() + 1;
} }
return std::make_unique<IntValueNode>(c); return std::make_unique<IntValueNode>(c);
} }
@@ -359,10 +359,10 @@ USql::max_function(const std::vector<std::unique_ptr<ValueNode>> &evaluatedPars,
if (agg_func_value->isNull()) { if (agg_func_value->isNull()) {
return std::make_unique<IntValueNode>(val); return std::make_unique<IntValueNode>(val);
} else { } else {
return std::make_unique<IntValueNode>(std::max(val, agg_func_value->getIntValue())); return std::make_unique<IntValueNode>(std::max(val, agg_func_value->getIntegerValue()));
} }
} else { } else {
return std::make_unique<IntValueNode>(agg_func_value->getIntValue()); return std::make_unique<IntValueNode>(agg_func_value->getIntegerValue());
} }
} else if (col_def_node->type == ColumnType::float_type) { } else if (col_def_node->type == ColumnType::float_type) {
if (!evaluatedPars[0]->isNull()) { if (!evaluatedPars[0]->isNull()) {
@@ -390,10 +390,10 @@ USql::min_function(const std::vector<std::unique_ptr<ValueNode>> &evaluatedPars,
if (agg_func_value->isNull()) { if (agg_func_value->isNull()) {
return std::make_unique<IntValueNode>(val); return std::make_unique<IntValueNode>(val);
} else { } else {
return std::make_unique<IntValueNode>(std::min(val, agg_func_value->getIntValue())); return std::make_unique<IntValueNode>(std::min(val, agg_func_value->getIntegerValue()));
} }
} else { } else {
return std::make_unique<IntValueNode>(agg_func_value->getIntValue()); return std::make_unique<IntValueNode>(agg_func_value->getIntegerValue());
} }
} else if (col_def_node->type == ColumnType::float_type) { } else if (col_def_node->type == ColumnType::float_type) {
if (!evaluatedPars[0]->isNull()) { if (!evaluatedPars[0]->isNull()) {