usql update

usql is still very primitive..it just barely works
This commit is contained in:
2021-07-23 00:00:39 +02:00
parent 4f113ab2c5
commit 5005644d98
26 changed files with 877 additions and 472 deletions

View File

@@ -1,6 +1,7 @@
#include "usql.h"
#include "exception.h"
#include "csvreader.h"
#include "ml_date.h"
#include <algorithm>
#include <fstream>
@@ -8,9 +9,14 @@
namespace usql {
std::unique_ptr<Table> USql::execute(const std::string &command) {
auto node = m_parser.parse(command);
try {
std::unique_ptr<Node> node = m_parser.parse(command);
return execute(*node);
} catch (std::exception &e) {
return create_stmt_result_table(-1, e.what());
}
return execute(*node);
}
std::unique_ptr<Table> USql::execute(Node &node) {
@@ -18,18 +24,22 @@ std::unique_ptr<Table> USql::execute(Node &node) {
switch (node.node_type) {
case NodeType::create_table:
return execute_create_table(static_cast<CreateTableNode &>(node));
case NodeType::insert_into:
return execute_insert_into_table(static_cast<InsertIntoTableNode &>(node));
case NodeType::select_from:
return execute_select(static_cast<SelectFromTableNode &>(node));
case NodeType::delete_from:
return execute_delete(static_cast<DeleteFromTableNode &>(node));
case NodeType::update_table:
return execute_update(static_cast<UpdateTableNode &>(node));
case NodeType::load_table:
return execute_load(static_cast<LoadIntoTableNode &>(node));
default:
return create_stmt_result_table(-1, "unknown statement");
case NodeType::create_table_as_select:
return execute_create_table_as_table(static_cast<CreateTableAsSelectNode &>(node));
case NodeType::insert_into:
return execute_insert_into_table(static_cast<InsertIntoTableNode &>(node));
case NodeType::select_from:
return execute_select(static_cast<SelectFromTableNode &>(node));
case NodeType::delete_from:
return execute_delete(static_cast<DeleteFromTableNode &>(node));
case NodeType::update_table:
return execute_update(static_cast<UpdateTableNode &>(node));
case NodeType::load_table:
return execute_load(static_cast<LoadIntoTableNode &>(node));
case NodeType::save_table:
return execute_save(static_cast<SaveTableNode &>(node));
default:
return create_stmt_result_table(-1, "unknown statement");
}
}
@@ -43,6 +53,28 @@ std::unique_ptr<Table> USql::execute_create_table(CreateTableNode &node) {
}
std::unique_ptr<Table> USql::execute_create_table_as_table(CreateTableAsSelectNode &node) {
// TODO check table does not exists
auto select = execute_select((SelectFromTableNode &) *node.select_table);
// create table
Table new_table{node.table_name, select->m_col_defs};
m_tables.push_back(new_table);
// copy rows
// must be here, if rows are put into new_table, they are lost during m_tables.push_table
Table *table = find_table(node.table_name);
for( Row& orig_row : select->m_rows) {
table->addCopyOfRow(orig_row);
}
select.release(); // is it correct? hoping not to release select table here and then when releasing CreateTableAsSelectNode
return create_stmt_result_table(0, "table created");
}
std::unique_ptr<Table> USql::execute_insert_into_table(InsertIntoTableNode &node) {
// TODO check column names.size = values.size
@@ -55,64 +87,56 @@ std::unique_ptr<Table> USql::execute_insert_into_table(InsertIntoTableNode &node
// copy values
for (size_t i = 0; i < node.cols_names.size(); i++) {
ColDefNode col_def = table_def->get_column_def(node.cols_names[i].name);
auto col_value = evalValueNode(table_def, new_row, node.cols_values[i].get());
// TODO validate value
if (col_def.type == ColumnType::integer_type) {
new_row.setColumnValue(col_def.order, std::stoi(node.cols_values[i].value));
} else if (col_def.type == ColumnType::float_type) {
new_row.setColumnValue(col_def.order, std::stof(node.cols_values[i].value));
} else {
new_row.setColumnValue(col_def.order, node.cols_values[i].value);
}
new_row.setColumnValue(&col_def, col_value.get());
}
// append new_row
table_def->addRow(new_row);
return create_stmt_result_table(0, "insert succeded");
return create_stmt_result_table(0, "insert succeeded");
}
std::unique_ptr<Table> USql::execute_select(SelectFromTableNode &node) {
// TODO create plan for accessing rows
// find source table
Table *table = find_table(node.table_name);
// create result table
std::vector<ColDefNode> result_tbl_col_defs{};
std::vector<int> source_table_col_index{};
int i = 0; // new column order
for (auto rc : node.cols_names) {
ColDefNode cdef = table->get_column_def(rc.name);
source_table_col_index.push_back(cdef.order);
auto col = ColDefNode(rc.name, cdef.type, i, cdef.length, cdef.null);
result_tbl_col_defs.push_back(col);
for (int i = 0; i < node.cols_names->size(); i++) {
auto [ src_tbl_col_index, rst_tbl_col_def ] = getColumnDefinition(table, &node.cols_names->operator[](i), i);
i++;
source_table_col_index.push_back(src_tbl_col_index);
result_tbl_col_defs.push_back(rst_tbl_col_def);
}
auto result = std::make_unique<Table>("result", result_tbl_col_defs);
// execute access plan
for (auto row = begin(table->m_rows); row != end(table->m_rows); ++row) {
// eval where for row
if (evalWhere(node.where.get(), table, row)) {
if (evalWhere(node.where.get(), table, *row)) {
// prepare empty row
Row new_row = result->createEmptyRow();
// copy column values
for (auto idx = 0; idx < result->columns_count(); idx++) {
auto row_col_index = source_table_col_index[idx];
ColValue *col_value = row->ithColumn(row_col_index);
if (result_tbl_col_defs[idx].type == ColumnType::integer_type)
new_row.setColumnValue(idx,
((ColIntegerValue *) col_value)->integerValue());
if (result_tbl_col_defs[idx].type == ColumnType::float_type)
new_row.setColumnValue(idx, col_value->floatValue());
if (result_tbl_col_defs[idx].type == ColumnType::varchar_type)
new_row.setColumnValue(idx, col_value->stringValue());
if (row_col_index == -1) { // TODO introduce constant here
auto evaluated_value = evalValueNode(table, *row, node.cols_names->operator[](idx).value.get());
ValueNode *col_value = evaluated_value.get();
new_row.setColumnValue(&result_tbl_col_defs[idx], col_value);
} else {
ColValue *col_value = row->ithColumn(row_col_index);
new_row.setColumnValue(&result_tbl_col_defs[idx], col_value);
}
}
// add row to result
@@ -123,17 +147,38 @@ std::unique_ptr<Table> USql::execute_select(SelectFromTableNode &node) {
return std::move(result);
}
std::tuple<int, ColDefNode> USql::getColumnDefinition(Table *table, SelectColNode *select_col_node, int col_order ) {
std::string new_col_name = select_col_node->name;
if (select_col_node->value->node_type == NodeType::column_name) {
ColDefNode src_cdef = table->get_column_def(new_col_name);
ColDefNode cdef = ColDefNode{new_col_name, src_cdef.type, col_order, src_cdef.length, src_cdef.null};
return std::make_tuple(src_cdef.order, cdef);
} else if (select_col_node->value->node_type == NodeType::function) {
auto node = static_cast<FunctionNode *>(select_col_node->value.get());
if (node->function == "to_string") {
ColDefNode cdef = ColDefNode{new_col_name, ColumnType::varchar_type, col_order, 64, true};
return std::make_tuple(-1, cdef);
} else if (node->function == "to_date") {
ColDefNode cdef = ColDefNode{new_col_name, ColumnType::integer_type, col_order, 1, true};
return std::make_tuple(-1, cdef);
}
throw Exception("Unsupported function");
}
throw Exception("Unsupported node type");
}
std::unique_ptr<Table> USql::execute_delete(DeleteFromTableNode &node) {
// TODO create plan for accessing rows
// find source table
Table *table = find_table(node.table_name);
// execute access plan
auto it = table->m_rows.begin();
for (; it != table->m_rows.end();) {
if (evalWhere(node.where.get(), table, it)) {
if (evalWhere(node.where.get(), table, *it)) {
// TODO this can be really expensive operation
it = table->m_rows.erase(it);
} else {
@@ -141,38 +186,25 @@ std::unique_ptr<Table> USql::execute_delete(DeleteFromTableNode &node) {
}
}
return create_stmt_result_table(0, "delete succeded");
return create_stmt_result_table(0, "delete succeeded");
}
std::unique_ptr<Table> USql::execute_update(UpdateTableNode &node) {
// TODO create plan for accessing rows
// find source table
Table *table = find_table(node.table_name);
// execute access plan
for (auto row = begin(table->m_rows); row != end(table->m_rows); ++row) {
// eval where for row
if (evalWhere(node.where.get(), table, row)) {
if (evalWhere(node.where.get(), table, *row)) {
int i = 0;
for (auto col : node.cols_names) {
// TODO cache it like in select
ColDefNode cdef = table->get_column_def(col.name);
for (const auto& col : node.cols_names) {
ColDefNode col_def = table->get_column_def(col.name); // TODO cache it like in select
std::unique_ptr<ValueNode> new_val = evalArithmeticOperator(col_def.type,
static_cast<ArithmeticalOperatorNode &>(*node.values[i]), table, *row);
std::unique_ptr<ValueNode> new_val = evalArithmetic(cdef.type,
static_cast<ArithmeticalOperatorNode &>(*node.values[i]),
table, row);
if (cdef.type == ColumnType::integer_type) {
row->setColumnValue(cdef.order, new_val->getIntValue());
} else if (cdef.type == ColumnType::float_type) {
row->setColumnValue(cdef.order, new_val->getDoubleValue());
} else if (cdef.type == ColumnType::varchar_type) {
row->setColumnValue(cdef.order, new_val->getStringValue());
} else {
throw Exception("Implement me!");
}
row->setColumnValue(&col_def, new_val.get());
i++;
}
}
@@ -208,7 +240,7 @@ std::unique_ptr<Table> USql::execute_load(LoadIntoTableNode &node) {
// TODO validate value
if (col_def.type == ColumnType::integer_type) {
new_row.setColumnValue(col_def.order, std::stoi(csv_line[i]));
new_row.setColumnValue(col_def.order, std::stol(csv_line[i]));
} else if (col_def.type == ColumnType::float_type) {
new_row.setColumnValue(col_def.order, std::stof(csv_line[i]));
} else {
@@ -224,154 +256,230 @@ std::unique_ptr<Table> USql::execute_load(LoadIntoTableNode &node) {
}
bool USql::evalWhere(Node *where, Table *table,
std::vector<Row, std::allocator<Row>>::iterator &row) const {
std::unique_ptr<Table> USql::execute_save(SaveTableNode &node) {
// find source table
Table *table_def = find_table(node.table_name);
// header
std::string out_string;
for(int i = 0; i < table_def->m_col_defs.size(); i++) {
if (i > 0) out_string += ",";
out_string += table_def->m_col_defs[i].name;
}
// rows
for (auto it = table_def->m_rows.begin() + 1; it != table_def->m_rows.end(); ++it) {
std::string csv_line;
for(int i = 0; i < table_def->m_col_defs.size(); i++) {
if (i > 0) csv_line += ",";
auto col = it->ithColumn(i);
if (!col->isNull()) {
csv_line += col->getStringValue(); // TODO handle enclosing commas etc
}
}
out_string += "\n";
out_string += csv_line;
}
// save data
std::ofstream file(node.filename);
file << out_string;
file.close();
return create_stmt_result_table(0, "save succeeded");
}
bool USql::evalWhere(Node *where, Table *table, Row &row) const {
switch (where->node_type) { // no where clause
case NodeType::true_node:
return true;
case NodeType::relational_operator: // just one condition
case NodeType::relational_operator: // just one condition
return evalRelationalOperator(*((RelationalOperatorNode *) where), table, row);
case NodeType::logical_operator:
return evalLogicalOperator(*((LogicalOperatorNode *) where), table, row);
default:
throw Exception("Wrong node type");
case NodeType::logical_operator:
return evalLogicalOperator(*((LogicalOperatorNode *) where), table, row);
default:
throw Exception("Wrong node type");
}
return false;
}
bool USql::evalRelationalOperator(const RelationalOperatorNode &filter, Table *table,
std::vector<Row, std::allocator<Row>>::iterator &row) const {
std::unique_ptr<ValueNode> left_value = evalNode(table, row, filter.left.get());
std::unique_ptr<ValueNode> right_value = evalNode(table, row, filter.right.get());
bool USql::evalRelationalOperator(const RelationalOperatorNode &filter, Table *table, Row &row) const {
std::unique_ptr<ValueNode> left_value = evalValueNode(table, row, filter.left.get());
std::unique_ptr<ValueNode> right_value = evalValueNode(table, row, filter.right.get());
double comparator;
if (left_value->node_type == NodeType::int_value && right_value->node_type == NodeType::int_value) {
comparator = left_value->getIntValue() - right_value->getIntValue();
} else if ((left_value->node_type == NodeType::int_value &&
right_value->node_type == NodeType::float_value) ||
(left_value->node_type == NodeType::float_value &&
right_value->node_type == NodeType::int_value) ||
(left_value->node_type == NodeType::float_value &&
right_value->node_type == NodeType::float_value)) {
} else if ((left_value->node_type == NodeType::int_value && right_value->node_type == NodeType::float_value) ||
(left_value->node_type == NodeType::float_value && right_value->node_type == NodeType::int_value) ||
(left_value->node_type == NodeType::float_value && right_value->node_type == NodeType::float_value)) {
comparator = left_value->getDoubleValue() - right_value->getDoubleValue();
} else if (left_value->node_type == NodeType::string_value ||
right_value->node_type == NodeType::string_value) {
} else if (left_value->node_type == NodeType::string_value || right_value->node_type == NodeType::string_value) {
comparator = left_value->getStringValue().compare(right_value->getStringValue());
} else {
// TODO throw exception
}
switch (filter.op) {
case RelationalOperatorType::equal:
return comparator == 0.0;
case RelationalOperatorType::not_equal:
return comparator != 0.0;
case RelationalOperatorType::greater:
return comparator > 0.0;
case RelationalOperatorType::greater_equal:
return comparator >= 0.0;
case RelationalOperatorType::lesser:
return comparator < 0.0;
case RelationalOperatorType::lesser_equal:
return comparator <= 0.0;
case RelationalOperatorType::not_equal:
return comparator != 0.0;
case RelationalOperatorType::greater:
return comparator > 0.0;
case RelationalOperatorType::greater_equal:
return comparator >= 0.0;
case RelationalOperatorType::lesser:
return comparator < 0.0;
case RelationalOperatorType::lesser_equal:
return comparator <= 0.0;
}
throw Exception("invalid relational operator");
}
std::unique_ptr<ValueNode>
USql::evalNode(Table *table, std::vector<Row, std::allocator<Row>>::iterator &row, Node *node) const {
if (node->node_type == NodeType::database_value) {
DatabaseValueNode *dvl = static_cast<DatabaseValueNode *>(node);
ColDefNode col_def = table->get_column_def(
dvl->col_name); // TODO optimize it to just get this def once
auto db_value = row->ithColumn(col_def.order);
std::unique_ptr<ValueNode> USql::evalValueNode(Table *table, Row &row, Node *node) {
if (node->node_type == NodeType::database_value || node->node_type == NodeType::column_name) { // TODO sjednotit
return evalDatabaseValueNode(table, row, node);
if (col_def.type == ColumnType::integer_type) {
return std::make_unique<IntValueNode>(db_value->integerValue());
}
if (col_def.type == ColumnType::float_type) {
return std::make_unique<FloatValueNode>(db_value->floatValue());
}
if (col_def.type == ColumnType::varchar_type) {
return std::make_unique<StringValueNode>(db_value->stringValue());
}
} else if (node->node_type == NodeType::int_value || node->node_type == NodeType::float_value || node->node_type == NodeType::string_value) {
return evalLiteralValueNode(table, row, node);
} else if (node->node_type == NodeType::int_value) {
IntValueNode *ivl = static_cast<IntValueNode *>(node);
} else if (node->node_type == NodeType::function) {
return evalFunctionValueNode(table, row, node);
}
throw Exception("unsupported node type");
}
std::unique_ptr<ValueNode> USql::evalDatabaseValueNode(Table *table, Row &row, Node *node) {
auto *dvl = static_cast<DatabaseValueNode *>(node);
ColDefNode col_def = table->get_column_def( dvl->col_name); // TODO optimize it to just get this def once
auto db_value = row.ithColumn(col_def.order);
if (col_def.type == ColumnType::integer_type) {
return std::make_unique<IntValueNode>(db_value->getIntValue());
}
if (col_def.type == ColumnType::float_type) {
return std::make_unique<DoubleValueNode>(db_value->getDoubleValue());
}
if (col_def.type == ColumnType::varchar_type) {
return std::make_unique<StringValueNode>(db_value->getStringValue());
}
throw Exception("unknown database value type");
}
std::unique_ptr<ValueNode> USql::evalLiteralValueNode(Table *table, Row &row, Node *node) {
if (node->node_type == NodeType::int_value) {
auto *ivl = static_cast<IntValueNode *>(node);
return std::make_unique<IntValueNode>(ivl->value);
} else if (node->node_type == NodeType::float_value) {
FloatValueNode *ivl = static_cast<FloatValueNode *>(node);
return std::make_unique<FloatValueNode>(ivl->value);
auto *ivl = static_cast<DoubleValueNode *>(node);
return std::make_unique<DoubleValueNode>(ivl->value);
} else if (node->node_type == NodeType::string_value) {
StringValueNode *ivl = static_cast<StringValueNode *>(node);
auto *ivl = static_cast<StringValueNode *>(node);
return std::make_unique<StringValueNode>(ivl->value);
}
throw Exception("invalid type");
}
bool USql::evalLogicalOperator(LogicalOperatorNode &node, Table *pTable,
std::vector<Row, std::allocator<Row>>::iterator &iter) const {
bool left = evalRelationalOperator(static_cast<const RelationalOperatorNode &>(*node.left), pTable, iter);
std::unique_ptr<ValueNode> USql::evalFunctionValueNode(Table *table, Row &row, Node *node) {
auto *fnc = static_cast<FunctionNode *>(node);
if ((node.op == LogicalOperatorType::and_operator && !left) ||
(node.op == LogicalOperatorType::or_operator && left))
std::vector<std::unique_ptr<ValueNode>> evaluatedPars;
for(auto & param : fnc->params) {
evaluatedPars.push_back(evalValueNode(table, row, param.get()));
}
// TODO use some enum
if (fnc->function == "lower") {
std::string str = evaluatedPars[0]->getStringValue();
std::transform(str.begin(), str.end(), str.begin(), [](unsigned char c) -> unsigned char { return std::tolower(c); });
return std::make_unique<StringValueNode>(str);
}
if (fnc->function == "upper") {
std::string str = evaluatedPars[0]->getStringValue();
std::transform(str.begin(), str.end(), str.begin(), [](unsigned char c) -> unsigned char { return std::toupper(c); });
return std::make_unique<StringValueNode>(str);
}
if (fnc->function == "to_date") {
std::string date = evaluatedPars[0]->getStringValue();
std::string format = evaluatedPars[1]->getStringValue();
long epoch_time = string_to_date(date, format);
return std::make_unique<IntValueNode>(epoch_time);
}
if (fnc->function == "to_string") {
long date = evaluatedPars[0]->getIntValue();
std::string format = evaluatedPars[1]->getStringValue();
std::string formated_date = date_to_string(date, format);
return std::make_unique<StringValueNode>(formated_date);
}
throw Exception("invalid function");
}
bool USql::evalLogicalOperator(LogicalOperatorNode &node, Table *pTable, Row &row) const {
bool left = evalRelationalOperator(static_cast<const RelationalOperatorNode &>(*node.left), pTable, row);
if ((node.op == LogicalOperatorType::and_operator && !left) || (node.op == LogicalOperatorType::or_operator && left))
return left;
bool right = evalRelationalOperator(static_cast<const RelationalOperatorNode &>(*node.right), pTable, iter);
bool right = evalRelationalOperator(static_cast<const RelationalOperatorNode &>(*node.right), pTable, row);
return right;
}
std::unique_ptr<ValueNode>
USql::evalArithmetic(ColumnType outType, ArithmeticalOperatorNode &node, Table *table,
std::vector<Row, std::allocator<Row>>::iterator &row) const {
std::unique_ptr<ValueNode> USql::evalArithmeticOperator(ColumnType outType, ArithmeticalOperatorNode &node, Table *table, Row &row) const {
if (node.op == ArithmeticalOperatorType::copy_value) {
return evalNode(table, row, node.left.get());
return evalValueNode(table, row, node.left.get());
}
std::unique_ptr<ValueNode> left = evalNode(table, row, node.left.get());
std::unique_ptr<ValueNode> right = evalNode(table, row, node.right.get());
std::unique_ptr<ValueNode> left = evalValueNode(table, row, node.left.get());
std::unique_ptr<ValueNode> right = evalValueNode(table, row, node.right.get());
if (outType == ColumnType::float_type) {
double l = ((ValueNode *) left.get())->getDoubleValue();
double r = ((ValueNode *) right.get())->getDoubleValue();
switch (node.op) {
case ArithmeticalOperatorType::plus_operator:
return std::make_unique<FloatValueNode>(l + r);
case ArithmeticalOperatorType::minus_operator:
return std::make_unique<FloatValueNode>(l - r);
case ArithmeticalOperatorType::multiply_operator:
return std::make_unique<FloatValueNode>(l * r);
case ArithmeticalOperatorType::divide_operator:
return std::make_unique<FloatValueNode>(l / r);
default:
throw Exception("implement me!!");
return std::make_unique<DoubleValueNode>(l + r);
case ArithmeticalOperatorType::minus_operator:
return std::make_unique<DoubleValueNode>(l - r);
case ArithmeticalOperatorType::multiply_operator:
return std::make_unique<DoubleValueNode>(l * r);
case ArithmeticalOperatorType::divide_operator:
return std::make_unique<DoubleValueNode>(l / r);
default:
throw Exception("implement me!!");
}
} else if (outType == ColumnType::integer_type) {
int l = ((ValueNode *) left.get())->getIntValue();
int r = ((ValueNode *) right.get())->getIntValue();
long l = ((ValueNode *) left.get())->getIntValue();
long r = ((ValueNode *) right.get())->getIntValue();
switch (node.op) {
case ArithmeticalOperatorType::plus_operator:
return std::make_unique<IntValueNode>(l + r);
case ArithmeticalOperatorType::minus_operator:
return std::make_unique<IntValueNode>(l - r);
case ArithmeticalOperatorType::multiply_operator:
return std::make_unique<IntValueNode>(l * r);
case ArithmeticalOperatorType::divide_operator:
return std::make_unique<IntValueNode>(l / r);
default:
throw Exception("implement me!!");
case ArithmeticalOperatorType::minus_operator:
return std::make_unique<IntValueNode>(l - r);
case ArithmeticalOperatorType::multiply_operator:
return std::make_unique<IntValueNode>(l * r);
case ArithmeticalOperatorType::divide_operator:
return std::make_unique<IntValueNode>(l / r);
default:
throw Exception("implement me!!");
}
} else if (outType == ColumnType::varchar_type) {
@@ -380,9 +488,8 @@ USql::evalArithmetic(ColumnType outType, ArithmeticalOperatorNode &node, Table *
switch (node.op) {
case ArithmeticalOperatorType::plus_operator:
return std::make_unique<StringValueNode>(l + r);
default:
throw Exception("implement me!!");
default:
throw Exception("implement me!!");
}
}
@@ -390,19 +497,7 @@ USql::evalArithmetic(ColumnType outType, ArithmeticalOperatorNode &node, Table *
}
Table *USql::find_table(const std::string name) {
auto name_cmp = [name](const Table& t) { return t.m_name == name; };
auto table_def = std::find_if(begin(m_tables), end(m_tables), name_cmp);
if (table_def != std::end(m_tables)) {
return table_def.operator->();
} else {
throw Exception("table not found (" + name + ")");
}
}
std::unique_ptr<Table> USql::create_stmt_result_table(int code, std::string text) {
std::unique_ptr<Table> USql::create_stmt_result_table(long code, const std::string& text) {
std::vector<ColDefNode> result_tbl_col_defs{};
result_tbl_col_defs.push_back(ColDefNode("code", ColumnType::integer_type, 0, 1, false));
result_tbl_col_defs.push_back(ColDefNode("desc", ColumnType::varchar_type, 1, 255, false));
@@ -417,4 +512,16 @@ std::unique_ptr<Table> USql::create_stmt_result_table(int code, std::string text
return std::move(table_def);
}
}
Table *USql::find_table(const std::string &name) {
auto name_cmp = [name](const Table& t) { return t.m_name == name; };
auto table_def = std::find_if(begin(m_tables), end(m_tables), name_cmp);
if (table_def != std::end(m_tables)) {
return table_def.operator->();
} else {
throw Exception("table not found (" + name + ")");
}
}
} // namespace