OmniSciDB  c07336695a
anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter Class Reference
+ Collaboration diagram for anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter:

Public Member Functions

 RelAlgAbstractInterpreter (const rapidjson::Value &query_ast, const Catalog_Namespace::Catalog &cat, RelAlgExecutor *ra_executor, const RenderQueryOptions *render_opts)
 
std::shared_ptr< const RelAlgNoderun ()
 

Private Member Functions

void dispatchNodes (const rapidjson::Value &rels)
 
std::shared_ptr< RelScandispatchTableScan (const rapidjson::Value &scan_ra)
 
std::shared_ptr< RelProjectdispatchProject (const rapidjson::Value &proj_ra)
 
std::shared_ptr< RelFilterdispatchFilter (const rapidjson::Value &filter_ra)
 
std::shared_ptr< RelAggregatedispatchAggregate (const rapidjson::Value &agg_ra)
 
std::shared_ptr< RelJoindispatchJoin (const rapidjson::Value &join_ra)
 
std::shared_ptr< RelSortdispatchSort (const rapidjson::Value &sort_ra)
 
std::shared_ptr< RelModifydispatchModify (const rapidjson::Value &logical_modify_ra)
 
std::shared_ptr< RelLogicalValuesdispatchLogicalValues (const rapidjson::Value &logical_values_ra)
 
const TableDescriptorgetTableFromScanNode (const rapidjson::Value &scan_ra) const
 
std::vector< std::string > getFieldNamesFromScanNode (const rapidjson::Value &scan_ra) const
 
std::vector< std::shared_ptr< const RelAlgNode > > getRelAlgInputs (const rapidjson::Value &node)
 
std::shared_ptr< const RelAlgNodeprev (const rapidjson::Value &crt_node)
 

Private Attributes

const rapidjson::Value & query_ast_
 
const Catalog_Namespace::Catalogcat_
 
std::vector< std::shared_ptr< RelAlgNode > > nodes_
 
RelAlgExecutorra_executor_
 
const RenderQueryOptionsrender_opts_
 

Detailed Description

Definition at line 1367 of file RelAlgAbstractInterpreter.cpp.

Constructor & Destructor Documentation

◆ RelAlgAbstractInterpreter()

anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::RelAlgAbstractInterpreter ( const rapidjson::Value &  query_ast,
const Catalog_Namespace::Catalog cat,
RelAlgExecutor ra_executor,
const RenderQueryOptions render_opts 
)
inline

Member Function Documentation

◆ dispatchAggregate()

std::shared_ptr<RelAggregate> anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::dispatchAggregate ( const rapidjson::Value &  agg_ra)
inlineprivate

Definition at line 1487 of file RelAlgAbstractInterpreter.cpp.

References CHECK, CHECK_EQ, field(), anonymous_namespace{RelAlgAbstractInterpreter.cpp}::indices_from_json_array(), anonymous_namespace{RelAlgAbstractInterpreter.cpp}::parse_aggregate_expr(), and anonymous_namespace{RelAlgAbstractInterpreter.cpp}::strings_from_json_array().

1487  {
1488  const auto inputs = getRelAlgInputs(agg_ra);
1489  CHECK_EQ(size_t(1), inputs.size());
1490  const auto fields = strings_from_json_array(field(agg_ra, "fields"));
1491  const auto group = indices_from_json_array(field(agg_ra, "group"));
1492  for (size_t i = 0; i < group.size(); ++i) {
1493  CHECK_EQ(i, group[i]);
1494  }
1495  if (agg_ra.HasMember("groups") || agg_ra.HasMember("indicator")) {
1496  throw QueryNotSupported("GROUP BY extensions not supported");
1497  }
1498  const auto& aggs_json_arr = field(agg_ra, "aggs");
1499  CHECK(aggs_json_arr.IsArray());
1500  std::vector<std::unique_ptr<const RexAgg>> aggs;
1501  for (auto aggs_json_arr_it = aggs_json_arr.Begin();
1502  aggs_json_arr_it != aggs_json_arr.End();
1503  ++aggs_json_arr_it) {
1504  aggs.emplace_back(parse_aggregate_expr(*aggs_json_arr_it));
1505  }
1506  return std::make_shared<RelAggregate>(group.size(), aggs, fields, inputs.front());
1507  }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
std::vector< size_t > indices_from_json_array(const rapidjson::Value &json_idx_arr) noexcept
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
std::vector< std::shared_ptr< const RelAlgNode > > getRelAlgInputs(const rapidjson::Value &node)
std::vector< std::string > strings_from_json_array(const rapidjson::Value &json_str_arr) noexcept
#define CHECK(condition)
Definition: Logger.h:187
std::unique_ptr< const RexAgg > parse_aggregate_expr(const rapidjson::Value &expr)
+ Here is the call graph for this function:

◆ dispatchFilter()

std::shared_ptr<RelFilter> anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::dispatchFilter ( const rapidjson::Value &  filter_ra)
inlineprivate

Definition at line 1478 of file RelAlgAbstractInterpreter.cpp.

References CHECK, CHECK_EQ, field(), anonymous_namespace{RelAlgAbstractInterpreter.cpp}::node_id(), and anonymous_namespace{RelAlgAbstractInterpreter.cpp}::parse_scalar_expr().

1478  {
1479  const auto inputs = getRelAlgInputs(filter_ra);
1480  CHECK_EQ(size_t(1), inputs.size());
1481  const auto id = node_id(filter_ra);
1482  CHECK(id);
1483  auto condition = parse_scalar_expr(field(filter_ra, "condition"), cat_, ra_executor_);
1484  return std::make_shared<RelFilter>(condition, inputs.front());
1485  }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
unsigned node_id(const rapidjson::Value &ra_node) noexcept
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
std::unique_ptr< const RexScalar > parse_scalar_expr(const rapidjson::Value &expr, const Catalog_Namespace::Catalog &cat, RelAlgExecutor *ra_executor)
std::vector< std::shared_ptr< const RelAlgNode > > getRelAlgInputs(const rapidjson::Value &node)
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

◆ dispatchJoin()

std::shared_ptr<RelJoin> anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::dispatchJoin ( const rapidjson::Value &  join_ra)
inlineprivate

Definition at line 1509 of file RelAlgAbstractInterpreter.cpp.

References CHECK_EQ, field(), json_str(), anonymous_namespace{RelAlgAbstractInterpreter.cpp}::parse_scalar_expr(), and anonymous_namespace{RelAlgAbstractInterpreter.cpp}::to_join_type().

1509  {
1510  const auto inputs = getRelAlgInputs(join_ra);
1511  CHECK_EQ(size_t(2), inputs.size());
1512  const auto join_type = to_join_type(json_str(field(join_ra, "joinType")));
1513  auto filter_rex = parse_scalar_expr(field(join_ra, "condition"), cat_, ra_executor_);
1514  return std::make_shared<RelJoin>(inputs[0], inputs[1], filter_rex, join_type);
1515  }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
std::unique_ptr< const RexScalar > parse_scalar_expr(const rapidjson::Value &expr, const Catalog_Namespace::Catalog &cat, RelAlgExecutor *ra_executor)
std::vector< std::shared_ptr< const RelAlgNode > > getRelAlgInputs(const rapidjson::Value &node)
JoinType to_join_type(const std::string &join_type_name)
+ Here is the call graph for this function:

◆ dispatchLogicalValues()

std::shared_ptr<RelLogicalValues> anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::dispatchLogicalValues ( const rapidjson::Value &  logical_values_ra)
inlineprivate

Definition at line 1581 of file RelAlgAbstractInterpreter.cpp.

References CHECK, field(), json_str(), and anonymous_namespace{RelAlgAbstractInterpreter.cpp}::parse_type().

1582  {
1583  const auto& tuple_type_arr = field(logical_values_ra, "type");
1584  CHECK(tuple_type_arr.IsArray());
1585  std::vector<TargetMetaInfo> tuple_type;
1586  for (auto tuple_type_arr_it = tuple_type_arr.Begin();
1587  tuple_type_arr_it != tuple_type_arr.End();
1588  ++tuple_type_arr_it) {
1589  const auto component_type = parse_type(*tuple_type_arr_it);
1590  const auto component_name = json_str(field(*tuple_type_arr_it, "name"));
1591  tuple_type.emplace_back(component_name, component_type);
1592  }
1593  const auto& inputs_arr = field(logical_values_ra, "inputs");
1594  CHECK(inputs_arr.IsArray());
1595  const auto& tuples_arr = field(logical_values_ra, "tuples");
1596  CHECK(tuples_arr.IsArray());
1597 
1598  if (inputs_arr.Size() || tuples_arr.Size()) {
1599  throw QueryNotSupported("Non-empty LogicalValues not supported yet");
1600  }
1601  return std::make_shared<RelLogicalValues>(tuple_type);
1602  }
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
SQLTypeInfo parse_type(const rapidjson::Value &type_obj)
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

◆ dispatchModify()

std::shared_ptr<RelModify> anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::dispatchModify ( const rapidjson::Value &  logical_modify_ra)
inlineprivate

Definition at line 1540 of file RelAlgAbstractInterpreter.cpp.

References CHECK, CHECK_EQ, RelModify::Delete, field(), json_bool(), json_str(), and RelModify::Update.

1540  {
1541  const auto inputs = getRelAlgInputs(logical_modify_ra);
1542  CHECK_EQ(size_t(1), inputs.size());
1543 
1544  const auto table_descriptor = getTableFromScanNode(logical_modify_ra);
1545  if (table_descriptor->isView) {
1546  throw std::runtime_error("UPDATE of a view is unsupported.");
1547  }
1548 
1549  bool flattened = json_bool(field(logical_modify_ra, "flattened"));
1550  std::string op = json_str(field(logical_modify_ra, "operation"));
1551  RelModify::TargetColumnList target_column_list;
1552 
1553  if (op == "UPDATE") {
1554  const auto& update_columns = field(logical_modify_ra, "updateColumnList");
1555  CHECK(update_columns.IsArray());
1556 
1557  for (auto column_arr_it = update_columns.Begin();
1558  column_arr_it != update_columns.End();
1559  ++column_arr_it) {
1560  target_column_list.push_back(column_arr_it->GetString());
1561  }
1562  }
1563 
1564  auto modify_node = std::make_shared<RelModify>(
1565  cat_, table_descriptor, flattened, op, target_column_list, inputs[0]);
1566  switch (modify_node->getOperation()) {
1568  modify_node->applyDeleteModificationsToInputNode();
1569  break;
1570  }
1572  modify_node->applyUpdateModificationsToInputNode();
1573  }
1574  default:
1575  break;
1576  }
1577 
1578  return modify_node;
1579  }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
std::vector< std::string > TargetColumnList
const bool json_bool(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:49
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
std::vector< std::shared_ptr< const RelAlgNode > > getRelAlgInputs(const rapidjson::Value &node)
#define CHECK(condition)
Definition: Logger.h:187
const TableDescriptor * getTableFromScanNode(const rapidjson::Value &scan_ra) const
+ Here is the call graph for this function:

◆ dispatchNodes()

void anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::dispatchNodes ( const rapidjson::Value &  rels)
inlineprivate

Definition at line 1424 of file RelAlgAbstractInterpreter.cpp.

References CHECK, CHECK_EQ, field(), json_str(), and anonymous_namespace{RelAlgAbstractInterpreter.cpp}::node_id().

1424  {
1425  for (auto rels_it = rels.Begin(); rels_it != rels.End(); ++rels_it) {
1426  const auto& crt_node = *rels_it;
1427  const auto id = node_id(crt_node);
1428  CHECK_EQ(static_cast<size_t>(id), nodes_.size());
1429  CHECK(crt_node.IsObject());
1430  std::shared_ptr<RelAlgNode> ra_node = nullptr;
1431  const auto rel_op = json_str(field(crt_node, "relOp"));
1432  if (rel_op == std::string("EnumerableTableScan")) {
1433  ra_node = dispatchTableScan(crt_node);
1434  } else if (rel_op == std::string("LogicalProject")) {
1435  ra_node = dispatchProject(crt_node);
1436  } else if (rel_op == std::string("LogicalFilter")) {
1437  ra_node = dispatchFilter(crt_node);
1438  } else if (rel_op == std::string("LogicalAggregate")) {
1439  ra_node = dispatchAggregate(crt_node);
1440  } else if (rel_op == std::string("LogicalJoin")) {
1441  ra_node = dispatchJoin(crt_node);
1442  } else if (rel_op == std::string("LogicalSort")) {
1443  ra_node = dispatchSort(crt_node);
1444  } else if (rel_op == std::string("LogicalValues")) {
1445  ra_node = dispatchLogicalValues(crt_node);
1446  } else if (rel_op == std::string("LogicalTableModify")) {
1447  ra_node = dispatchModify(crt_node);
1448  } else {
1449  throw QueryNotSupported(std::string("Node ") + rel_op + " not supported yet");
1450  }
1451  nodes_.push_back(ra_node);
1452  }
1453  }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
std::shared_ptr< RelProject > dispatchProject(const rapidjson::Value &proj_ra)
std::shared_ptr< RelLogicalValues > dispatchLogicalValues(const rapidjson::Value &logical_values_ra)
unsigned node_id(const rapidjson::Value &ra_node) noexcept
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
std::shared_ptr< RelJoin > dispatchJoin(const rapidjson::Value &join_ra)
std::shared_ptr< RelSort > dispatchSort(const rapidjson::Value &sort_ra)
std::shared_ptr< RelAggregate > dispatchAggregate(const rapidjson::Value &agg_ra)
std::shared_ptr< RelModify > dispatchModify(const rapidjson::Value &logical_modify_ra)
#define CHECK(condition)
Definition: Logger.h:187
std::shared_ptr< RelScan > dispatchTableScan(const rapidjson::Value &scan_ra)
std::shared_ptr< RelFilter > dispatchFilter(const rapidjson::Value &filter_ra)
+ Here is the call graph for this function:

◆ dispatchProject()

std::shared_ptr<RelProject> anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::dispatchProject ( const rapidjson::Value &  proj_ra)
inlineprivate

Definition at line 1463 of file RelAlgAbstractInterpreter.cpp.

References CHECK, CHECK_EQ, field(), anonymous_namespace{RelAlgAbstractInterpreter.cpp}::parse_scalar_expr(), and anonymous_namespace{RelAlgAbstractInterpreter.cpp}::strings_from_json_array().

1463  {
1464  const auto inputs = getRelAlgInputs(proj_ra);
1465  CHECK_EQ(size_t(1), inputs.size());
1466  const auto& exprs_json = field(proj_ra, "exprs");
1467  CHECK(exprs_json.IsArray());
1468  std::vector<std::unique_ptr<const RexScalar>> exprs;
1469  for (auto exprs_json_it = exprs_json.Begin(); exprs_json_it != exprs_json.End();
1470  ++exprs_json_it) {
1471  exprs.emplace_back(parse_scalar_expr(*exprs_json_it, cat_, ra_executor_));
1472  }
1473  const auto& fields = field(proj_ra, "fields");
1474  return std::make_shared<RelProject>(
1475  exprs, strings_from_json_array(fields), inputs.front());
1476  }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
std::unique_ptr< const RexScalar > parse_scalar_expr(const rapidjson::Value &expr, const Catalog_Namespace::Catalog &cat, RelAlgExecutor *ra_executor)
std::vector< std::shared_ptr< const RelAlgNode > > getRelAlgInputs(const rapidjson::Value &node)
std::vector< std::string > strings_from_json_array(const rapidjson::Value &json_str_arr) noexcept
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

◆ dispatchSort()

std::shared_ptr<RelSort> anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::dispatchSort ( const rapidjson::Value &  sort_ra)
inlineprivate

Definition at line 1517 of file RelAlgAbstractInterpreter.cpp.

References CHECK, CHECK_EQ, field(), anonymous_namespace{RelAlgAbstractInterpreter.cpp}::get_int_literal_field(), json_i64(), anonymous_namespace{RelAlgAbstractInterpreter.cpp}::parse_nulls_position(), and anonymous_namespace{RelAlgAbstractInterpreter.cpp}::parse_sort_direction().

1517  {
1518  const auto inputs = getRelAlgInputs(sort_ra);
1519  CHECK_EQ(size_t(1), inputs.size());
1520  std::vector<SortField> collation;
1521  const auto& collation_arr = field(sort_ra, "collation");
1522  CHECK(collation_arr.IsArray());
1523  for (auto collation_arr_it = collation_arr.Begin();
1524  collation_arr_it != collation_arr.End();
1525  ++collation_arr_it) {
1526  const size_t field_idx = json_i64(field(*collation_arr_it, "field"));
1527  const auto sort_dir = parse_sort_direction(*collation_arr_it);
1528  const auto null_pos = parse_nulls_position(*collation_arr_it);
1529  collation.emplace_back(field_idx, sort_dir, null_pos);
1530  }
1531  auto limit = get_int_literal_field(sort_ra, "fetch", -1);
1532  if (limit == 0) {
1533  throw QueryNotSupported("LIMIT 0 not supported");
1534  }
1535  const auto offset = get_int_literal_field(sort_ra, "offset", 0);
1536  return std::make_shared<RelSort>(
1537  collation, limit > 0 ? limit : 0, offset, inputs.front());
1538  }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
NullSortedPosition parse_nulls_position(const rapidjson::Value &collation)
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
const int64_t json_i64(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:39
std::vector< std::shared_ptr< const RelAlgNode > > getRelAlgInputs(const rapidjson::Value &node)
int64_t get_int_literal_field(const rapidjson::Value &obj, const char field[], const int64_t default_val) noexcept
#define CHECK(condition)
Definition: Logger.h:187
SortDirection parse_sort_direction(const rapidjson::Value &collation)
+ Here is the call graph for this function:

◆ dispatchTableScan()

std::shared_ptr<RelScan> anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::dispatchTableScan ( const rapidjson::Value &  scan_ra)
inlineprivate

Definition at line 1455 of file RelAlgAbstractInterpreter.cpp.

References CHECK, and anonymous_namespace{RelAlgAbstractInterpreter.cpp}::check_empty_inputs_field().

1455  {
1456  check_empty_inputs_field(scan_ra);
1457  CHECK(scan_ra.IsObject());
1458  const auto td = getTableFromScanNode(scan_ra);
1459  const auto field_names = getFieldNamesFromScanNode(scan_ra);
1460  return std::make_shared<RelScan>(td, field_names);
1461  }
std::vector< std::string > getFieldNamesFromScanNode(const rapidjson::Value &scan_ra) const
void check_empty_inputs_field(const rapidjson::Value &node) noexcept
#define CHECK(condition)
Definition: Logger.h:187
const TableDescriptor * getTableFromScanNode(const rapidjson::Value &scan_ra) const
+ Here is the call graph for this function:

◆ getFieldNamesFromScanNode()

std::vector<std::string> anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::getFieldNamesFromScanNode ( const rapidjson::Value &  scan_ra) const
inlineprivate

Definition at line 1613 of file RelAlgAbstractInterpreter.cpp.

References field(), and anonymous_namespace{RelAlgAbstractInterpreter.cpp}::strings_from_json_array().

1614  {
1615  const auto& fields_json = field(scan_ra, "fieldNames");
1616  return strings_from_json_array(fields_json);
1617  }
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
std::vector< std::string > strings_from_json_array(const rapidjson::Value &json_str_arr) noexcept
+ Here is the call graph for this function:

◆ getRelAlgInputs()

std::vector<std::shared_ptr<const RelAlgNode> > anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::getRelAlgInputs ( const rapidjson::Value &  node)
inlineprivate

Definition at line 1619 of file RelAlgAbstractInterpreter.cpp.

References field(), and anonymous_namespace{RelAlgAbstractInterpreter.cpp}::strings_from_json_array().

1620  {
1621  if (node.HasMember("inputs")) {
1622  const auto str_input_ids = strings_from_json_array(field(node, "inputs"));
1623  std::vector<std::shared_ptr<const RelAlgNode>> ra_inputs;
1624  for (const auto str_id : str_input_ids) {
1625  ra_inputs.push_back(nodes_[std::stoi(str_id)]);
1626  }
1627  return ra_inputs;
1628  }
1629  return {prev(node)};
1630  }
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
std::vector< std::string > strings_from_json_array(const rapidjson::Value &json_str_arr) noexcept
std::shared_ptr< const RelAlgNode > prev(const rapidjson::Value &crt_node)
+ Here is the call graph for this function:

◆ getTableFromScanNode()

const TableDescriptor* anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::getTableFromScanNode ( const rapidjson::Value &  scan_ra) const
inlineprivate

Definition at line 1604 of file RelAlgAbstractInterpreter.cpp.

References CHECK, CHECK_EQ, and field().

1604  {
1605  const auto& table_json = field(scan_ra, "table");
1606  CHECK(table_json.IsArray());
1607  CHECK_EQ(unsigned(2), table_json.Size());
1608  const auto td = cat_.getMetadataForTable(table_json[1].GetString());
1609  CHECK(td);
1610  return td;
1611  }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

◆ prev()

std::shared_ptr<const RelAlgNode> anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::prev ( const rapidjson::Value &  crt_node)
inlineprivate

Definition at line 1632 of file RelAlgAbstractInterpreter.cpp.

References CHECK, CHECK_EQ, and anonymous_namespace{RelAlgAbstractInterpreter.cpp}::node_id().

1632  {
1633  const auto id = node_id(crt_node);
1634  CHECK(id);
1635  CHECK_EQ(static_cast<size_t>(id), nodes_.size());
1636  return nodes_.back();
1637  }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
unsigned node_id(const rapidjson::Value &ra_node) noexcept
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

◆ run()

std::shared_ptr<const RelAlgNode> anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::run ( )
inline

Definition at line 1378 of file RelAlgAbstractInterpreter.cpp.

References alterRAForRender(), anonymous_namespace{RelAlgAbstractInterpreter.cpp}::bind_inputs(), CHECK, anonymous_namespace{RelAlgAbstractInterpreter.cpp}::coalesce_nodes(), anonymous_namespace{RelLeftDeepInnerJoin.cpp}::create_left_deep_join(), eliminate_dead_columns(), eliminate_identical_copy(), field(), fold_filters(), get_left_deep_join_root(), hoist_filter_cond_to_cross_join(), anonymous_namespace{RelAlgAbstractInterpreter.cpp}::mark_nops(), simplify_sort(), and sink_projected_boolean_expr_to_join().

Referenced by anonymous_namespace{RelAlgAbstractInterpreter.cpp}::ra_interpret().

1378  {
1379  const auto& rels = field(query_ast_, "rels");
1380  CHECK(rels.IsArray());
1381  try {
1382  dispatchNodes(rels);
1383  } catch (const QueryNotSupported&) {
1384  throw;
1385  }
1386  CHECK(!nodes_.empty());
1388 
1389  if (render_opts_) {
1390  // Alter the RA for render. Do this before any flattening/optimizations are done to
1391  // the tree.
1393  }
1394 
1395  mark_nops(nodes_);
1400  std::vector<const RelAlgNode*> filtered_left_deep_joins;
1401  std::vector<const RelAlgNode*> left_deep_joins;
1402  for (const auto& node : nodes_) {
1403  const auto left_deep_join_root = get_left_deep_join_root(node);
1404  // The filter which starts a left-deep join pattern must not be coalesced
1405  // since it contains (part of) the join condition.
1406  if (left_deep_join_root) {
1407  left_deep_joins.push_back(left_deep_join_root.get());
1408  if (std::dynamic_pointer_cast<const RelFilter>(left_deep_join_root)) {
1409  filtered_left_deep_joins.push_back(left_deep_join_root.get());
1410  }
1411  }
1412  }
1413  if (filtered_left_deep_joins.empty()) {
1415  }
1416  eliminate_dead_columns(nodes_);
1417  coalesce_nodes(nodes_, left_deep_joins);
1418  CHECK(nodes_.back().unique());
1419  create_left_deep_join(nodes_);
1420  return nodes_.back();
1421  }
void alterRAForRender(std::vector< std::shared_ptr< RelAlgNode >> &nodes, const RenderQueryOptions &render_opts)
void hoist_filter_cond_to_cross_join(std::vector< std::shared_ptr< RelAlgNode >> &nodes) noexcept
std::shared_ptr< const RelAlgNode > get_left_deep_join_root(const std::shared_ptr< RelAlgNode > &node)
void sink_projected_boolean_expr_to_join(std::vector< std::shared_ptr< RelAlgNode >> &nodes) noexcept
void eliminate_identical_copy(std::vector< std::shared_ptr< RelAlgNode >> &nodes) noexcept
std::pair< std::shared_ptr< RelLeftDeepInnerJoin >, std::shared_ptr< const RelAlgNode > > create_left_deep_join(const std::shared_ptr< RelAlgNode > &left_deep_join_root)
void simplify_sort(std::vector< std::shared_ptr< RelAlgNode >> &nodes) noexcept
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
void bind_inputs(const std::vector< std::shared_ptr< RelAlgNode >> &nodes) noexcept
void coalesce_nodes(std::vector< std::shared_ptr< RelAlgNode >> &nodes, const std::vector< const RelAlgNode *> &left_deep_joins)
#define CHECK(condition)
Definition: Logger.h:187
void fold_filters(std::vector< std::shared_ptr< RelAlgNode >> &nodes) noexcept
void mark_nops(const std::vector< std::shared_ptr< RelAlgNode >> &nodes) noexcept
void eliminate_dead_columns(std::vector< std::shared_ptr< RelAlgNode >> &nodes) noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ cat_

const Catalog_Namespace::Catalog& anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::cat_
private

Definition at line 1640 of file RelAlgAbstractInterpreter.cpp.

◆ nodes_

std::vector<std::shared_ptr<RelAlgNode> > anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::nodes_
private

Definition at line 1641 of file RelAlgAbstractInterpreter.cpp.

◆ query_ast_

const rapidjson::Value& anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::query_ast_
private

Definition at line 1639 of file RelAlgAbstractInterpreter.cpp.

◆ ra_executor_

RelAlgExecutor* anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::ra_executor_
private

Definition at line 1642 of file RelAlgAbstractInterpreter.cpp.

◆ render_opts_

const RenderQueryOptions* anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::render_opts_
private

Definition at line 1643 of file RelAlgAbstractInterpreter.cpp.


The documentation for this class was generated from the following file: