OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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< RelTableFunctiondispatchTableFunction (const rapidjson::Value &table_func_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 1787 of file RelAlgAbstractInterpreter.cpp.

Constructor & Destructor Documentation

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

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

Definition at line 1910 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().

1910  {
1911  const auto inputs = getRelAlgInputs(agg_ra);
1912  CHECK_EQ(size_t(1), inputs.size());
1913  const auto fields = strings_from_json_array(field(agg_ra, "fields"));
1914  const auto group = indices_from_json_array(field(agg_ra, "group"));
1915  for (size_t i = 0; i < group.size(); ++i) {
1916  CHECK_EQ(i, group[i]);
1917  }
1918  if (agg_ra.HasMember("groups") || agg_ra.HasMember("indicator")) {
1919  throw QueryNotSupported("GROUP BY extensions not supported");
1920  }
1921  const auto& aggs_json_arr = field(agg_ra, "aggs");
1922  CHECK(aggs_json_arr.IsArray());
1923  std::vector<std::unique_ptr<const RexAgg>> aggs;
1924  for (auto aggs_json_arr_it = aggs_json_arr.Begin();
1925  aggs_json_arr_it != aggs_json_arr.End();
1926  ++aggs_json_arr_it) {
1927  aggs.emplace_back(parse_aggregate_expr(*aggs_json_arr_it));
1928  }
1929  return std::make_shared<RelAggregate>(group.size(), aggs, fields, inputs.front());
1930  }
#define CHECK_EQ(x, y)
Definition: Logger.h:198
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
CHECK(cgen_state)
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
std::unique_ptr< const RexAgg > parse_aggregate_expr(const rapidjson::Value &expr)

+ Here is the call graph for this function:

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

Definition at line 1901 of file RelAlgAbstractInterpreter.cpp.

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

1901  {
1902  const auto inputs = getRelAlgInputs(filter_ra);
1903  CHECK_EQ(size_t(1), inputs.size());
1904  const auto id = node_id(filter_ra);
1905  CHECK(id);
1906  auto condition = parse_scalar_expr(field(filter_ra, "condition"), cat_, ra_executor_);
1907  return std::make_shared<RelFilter>(condition, inputs.front());
1908  }
#define CHECK_EQ(x, y)
Definition: Logger.h:198
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)
CHECK(cgen_state)
std::vector< std::shared_ptr< const RelAlgNode > > getRelAlgInputs(const rapidjson::Value &node)

+ Here is the call graph for this function:

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

Definition at line 1932 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().

1932  {
1933  const auto inputs = getRelAlgInputs(join_ra);
1934  CHECK_EQ(size_t(2), inputs.size());
1935  const auto join_type = to_join_type(json_str(field(join_ra, "joinType")));
1936  auto filter_rex = parse_scalar_expr(field(join_ra, "condition"), cat_, ra_executor_);
1937  return std::make_shared<RelJoin>(inputs[0], inputs[1], filter_rex, join_type);
1938  }
#define CHECK_EQ(x, y)
Definition: Logger.h:198
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:

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

Definition at line 2085 of file RelAlgAbstractInterpreter.cpp.

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

2086  {
2087  const auto& tuple_type_arr = field(logical_values_ra, "type");
2088  CHECK(tuple_type_arr.IsArray());
2089  std::vector<TargetMetaInfo> tuple_type;
2090  for (auto tuple_type_arr_it = tuple_type_arr.Begin();
2091  tuple_type_arr_it != tuple_type_arr.End();
2092  ++tuple_type_arr_it) {
2093  const auto component_type = parse_type(*tuple_type_arr_it);
2094  const auto component_name = json_str(field(*tuple_type_arr_it, "name"));
2095  tuple_type.emplace_back(component_name, component_type);
2096  }
2097  const auto& inputs_arr = field(logical_values_ra, "inputs");
2098  CHECK(inputs_arr.IsArray());
2099  const auto& tuples_arr = field(logical_values_ra, "tuples");
2100  CHECK(tuples_arr.IsArray());
2101 
2102  if (inputs_arr.Size() || tuples_arr.Size()) {
2103  throw QueryNotSupported("Non-empty LogicalValues not supported yet");
2104  }
2105  return std::make_shared<RelLogicalValues>(tuple_type);
2106  }
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
CHECK(cgen_state)
SQLTypeInfo parse_type(const rapidjson::Value &type_obj)

+ Here is the call graph for this function:

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

Definition at line 1962 of file RelAlgAbstractInterpreter.cpp.

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

1962  {
1963  const auto inputs = getRelAlgInputs(logical_modify_ra);
1964  CHECK_EQ(size_t(1), inputs.size());
1965 
1966  const auto table_descriptor = getTableFromScanNode(logical_modify_ra);
1967  if (table_descriptor->isView) {
1968  throw std::runtime_error("UPDATE of a view is unsupported.");
1969  }
1970 
1971  bool flattened = json_bool(field(logical_modify_ra, "flattened"));
1972  std::string op = json_str(field(logical_modify_ra, "operation"));
1973  RelModify::TargetColumnList target_column_list;
1974 
1975  if (op == "UPDATE") {
1976  const auto& update_columns = field(logical_modify_ra, "updateColumnList");
1977  CHECK(update_columns.IsArray());
1978 
1979  for (auto column_arr_it = update_columns.Begin();
1980  column_arr_it != update_columns.End();
1981  ++column_arr_it) {
1982  target_column_list.push_back(column_arr_it->GetString());
1983  }
1984  }
1985 
1986  auto modify_node = std::make_shared<RelModify>(
1987  cat_, table_descriptor, flattened, op, target_column_list, inputs[0]);
1988  switch (modify_node->getOperation()) {
1990  modify_node->applyDeleteModificationsToInputNode();
1991  break;
1992  }
1994  modify_node->applyUpdateModificationsToInputNode();
1995  }
1996  default:
1997  break;
1998  }
1999 
2000  return modify_node;
2001  }
#define CHECK_EQ(x, y)
Definition: Logger.h:198
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
CHECK(cgen_state)
std::vector< std::shared_ptr< const RelAlgNode > > getRelAlgInputs(const rapidjson::Value &node)
const TableDescriptor * getTableFromScanNode(const rapidjson::Value &scan_ra) const

+ Here is the call graph for this function:

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

Definition at line 1845 of file RelAlgAbstractInterpreter.cpp.

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

1845  {
1846  for (auto rels_it = rels.Begin(); rels_it != rels.End(); ++rels_it) {
1847  const auto& crt_node = *rels_it;
1848  const auto id = node_id(crt_node);
1849  CHECK_EQ(static_cast<size_t>(id), nodes_.size());
1850  CHECK(crt_node.IsObject());
1851  std::shared_ptr<RelAlgNode> ra_node = nullptr;
1852  const auto rel_op = json_str(field(crt_node, "relOp"));
1853  if (rel_op == std::string("EnumerableTableScan")) {
1854  ra_node = dispatchTableScan(crt_node);
1855  } else if (rel_op == std::string("LogicalProject")) {
1856  ra_node = dispatchProject(crt_node);
1857  } else if (rel_op == std::string("LogicalFilter")) {
1858  ra_node = dispatchFilter(crt_node);
1859  } else if (rel_op == std::string("LogicalAggregate")) {
1860  ra_node = dispatchAggregate(crt_node);
1861  } else if (rel_op == std::string("LogicalJoin")) {
1862  ra_node = dispatchJoin(crt_node);
1863  } else if (rel_op == std::string("LogicalSort")) {
1864  ra_node = dispatchSort(crt_node);
1865  } else if (rel_op == std::string("LogicalValues")) {
1866  ra_node = dispatchLogicalValues(crt_node);
1867  } else if (rel_op == std::string("LogicalTableModify")) {
1868  ra_node = dispatchModify(crt_node);
1869  } else if (rel_op == std::string("LogicalTableFunctionScan")) {
1870  ra_node = dispatchTableFunction(crt_node);
1871  } else {
1872  throw QueryNotSupported(std::string("Node ") + rel_op + " not supported yet");
1873  }
1874  nodes_.push_back(ra_node);
1875  }
1876  }
#define CHECK_EQ(x, y)
Definition: Logger.h:198
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
CHECK(cgen_state)
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)
std::shared_ptr< RelScan > dispatchTableScan(const rapidjson::Value &scan_ra)
std::shared_ptr< RelFilter > dispatchFilter(const rapidjson::Value &filter_ra)
std::shared_ptr< RelTableFunction > dispatchTableFunction(const rapidjson::Value &table_func_ra)

+ Here is the call graph for this function:

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

Definition at line 1886 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().

1886  {
1887  const auto inputs = getRelAlgInputs(proj_ra);
1888  CHECK_EQ(size_t(1), inputs.size());
1889  const auto& exprs_json = field(proj_ra, "exprs");
1890  CHECK(exprs_json.IsArray());
1891  std::vector<std::unique_ptr<const RexScalar>> exprs;
1892  for (auto exprs_json_it = exprs_json.Begin(); exprs_json_it != exprs_json.End();
1893  ++exprs_json_it) {
1894  exprs.emplace_back(parse_scalar_expr(*exprs_json_it, cat_, ra_executor_));
1895  }
1896  const auto& fields = field(proj_ra, "fields");
1897  return std::make_shared<RelProject>(
1898  exprs, strings_from_json_array(fields), inputs.front());
1899  }
#define CHECK_EQ(x, y)
Definition: Logger.h:198
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)
CHECK(cgen_state)
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

+ Here is the call graph for this function:

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

Definition at line 1940 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().

1940  {
1941  const auto inputs = getRelAlgInputs(sort_ra);
1942  CHECK_EQ(size_t(1), inputs.size());
1943  std::vector<SortField> collation;
1944  const auto& collation_arr = field(sort_ra, "collation");
1945  CHECK(collation_arr.IsArray());
1946  for (auto collation_arr_it = collation_arr.Begin();
1947  collation_arr_it != collation_arr.End();
1948  ++collation_arr_it) {
1949  const size_t field_idx = json_i64(field(*collation_arr_it, "field"));
1950  const auto sort_dir = parse_sort_direction(*collation_arr_it);
1951  const auto null_pos = parse_nulls_position(*collation_arr_it);
1952  collation.emplace_back(field_idx, sort_dir, null_pos);
1953  }
1954  auto limit = get_int_literal_field(sort_ra, "fetch", -1);
1955  const auto offset = get_int_literal_field(sort_ra, "offset", 0);
1956  auto ret = std::make_shared<RelSort>(
1957  collation, limit > 0 ? limit : 0, offset, inputs.front());
1958  ret->setEmptyResult(limit == 0);
1959  return ret;
1960  }
#define CHECK_EQ(x, y)
Definition: Logger.h:198
NullSortedPosition parse_nulls_position(const rapidjson::Value &collation)
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
CHECK(cgen_state)
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
SortDirection parse_sort_direction(const rapidjson::Value &collation)

+ Here is the call graph for this function:

std::shared_ptr<RelTableFunction> anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RelAlgAbstractInterpreter::dispatchTableFunction ( const rapidjson::Value &  table_func_ra)
inlineprivate

Definition at line 2003 of file RelAlgAbstractInterpreter.cpp.

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

2004  {
2005  const auto inputs = getRelAlgInputs(table_func_ra);
2006  CHECK_EQ(size_t(1), inputs.size());
2007 
2008  const auto& invocation = field(table_func_ra, "invocation");
2009  CHECK(invocation.IsObject());
2010 
2011  const auto& operands = field(invocation, "operands");
2012  CHECK(operands.IsArray());
2013  CHECK_GE(operands.Size(), unsigned(0));
2014 
2015  std::vector<const Rex*> col_inputs;
2016  std::vector<std::unique_ptr<const RexScalar>> table_func_inputs;
2017  std::vector<std::string> fields;
2018 
2019  for (auto exprs_json_it = operands.Begin(); exprs_json_it != operands.End();
2020  ++exprs_json_it) {
2021  const auto& expr_json = *exprs_json_it;
2022  CHECK(expr_json.IsObject());
2023 
2024  if (expr_json.HasMember("op")) {
2025  const auto op_str = json_str(field(expr_json, "op"));
2026  if (op_str == "CAST" && expr_json.HasMember("type")) {
2027  const auto& expr_type = field(expr_json, "type");
2028  CHECK(expr_type.IsObject());
2029  CHECK(expr_type.HasMember("type"));
2030  const auto& expr_type_name = json_str(field(expr_type, "type"));
2031  if (expr_type_name == "CURSOR") {
2032  CHECK(expr_json.HasMember("operands"));
2033  const auto& expr_operands = field(expr_json, "operands");
2034  CHECK(expr_operands.IsArray());
2035  if (expr_operands.Size() != 1) {
2036  throw std::runtime_error(
2037  "Table functions currently only support one ResultSet input");
2038  }
2039 
2040  CHECK(expr_json.HasMember("type"));
2041  const auto& expr_types = field(invocation, "type");
2042  CHECK(expr_types.IsArray());
2043 
2044  const auto prior_node = prev(table_func_ra);
2045  CHECK(prior_node);
2046  CHECK_EQ(prior_node->size(), expr_types.Size());
2047 
2048  // Forward the values from the prior node as RexInputs
2049  for (size_t i = 0; i < prior_node->size(); i++) {
2050  table_func_inputs.emplace_back(std::make_unique<RexAbstractInput>(i));
2051  col_inputs.emplace_back(table_func_inputs.back().get());
2052  }
2053  continue;
2054  }
2055  }
2056  }
2057  table_func_inputs.emplace_back(
2058  parse_scalar_expr(*exprs_json_it, cat_, ra_executor_));
2059  }
2060 
2061  const auto& op_name = field(invocation, "op");
2062  CHECK(op_name.IsString());
2063 
2064  std::vector<std::unique_ptr<const RexScalar>> table_function_projected_outputs;
2065  const auto& row_types = field(table_func_ra, "rowType");
2066  CHECK(row_types.IsArray());
2067  CHECK_GE(row_types.Size(), unsigned(0));
2068  const auto& row_types_array = row_types.GetArray();
2069 
2070  for (size_t i = 0; i < row_types_array.Size(); i++) {
2071  // We don't care about the type information in rowType -- replace each output with a
2072  // reference to be resolved later in the translator
2073  table_function_projected_outputs.emplace_back(std::make_unique<RexRef>(i));
2074  fields.emplace_back("");
2075  }
2076 
2077  return std::make_shared<RelTableFunction>(op_name.GetString(),
2078  inputs[0],
2079  fields,
2080  col_inputs,
2081  table_func_inputs,
2082  table_function_projected_outputs);
2083  }
#define CHECK_EQ(x, y)
Definition: Logger.h:198
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
#define CHECK_GE(x, y)
Definition: Logger.h:203
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)
CHECK(cgen_state)
std::vector< std::shared_ptr< const RelAlgNode > > getRelAlgInputs(const rapidjson::Value &node)
std::shared_ptr< const RelAlgNode > prev(const rapidjson::Value &crt_node)

+ Here is the call graph for this function:

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

Definition at line 1878 of file RelAlgAbstractInterpreter.cpp.

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

1878  {
1879  check_empty_inputs_field(scan_ra);
1880  CHECK(scan_ra.IsObject());
1881  const auto td = getTableFromScanNode(scan_ra);
1882  const auto field_names = getFieldNamesFromScanNode(scan_ra);
1883  return std::make_shared<RelScan>(td, field_names);
1884  }
CHECK(cgen_state)
std::vector< std::string > getFieldNamesFromScanNode(const rapidjson::Value &scan_ra) const
void check_empty_inputs_field(const rapidjson::Value &node) noexcept
const TableDescriptor * getTableFromScanNode(const rapidjson::Value &scan_ra) const

+ Here is the call graph for this function:

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

Definition at line 2117 of file RelAlgAbstractInterpreter.cpp.

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

2118  {
2119  const auto& fields_json = field(scan_ra, "fieldNames");
2120  return strings_from_json_array(fields_json);
2121  }
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:

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

Definition at line 2123 of file RelAlgAbstractInterpreter.cpp.

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

2124  {
2125  if (node.HasMember("inputs")) {
2126  const auto str_input_ids = strings_from_json_array(field(node, "inputs"));
2127  std::vector<std::shared_ptr<const RelAlgNode>> ra_inputs;
2128  for (const auto str_id : str_input_ids) {
2129  ra_inputs.push_back(nodes_[std::stoi(str_id)]);
2130  }
2131  return ra_inputs;
2132  }
2133  return {prev(node)};
2134  }
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:

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

Definition at line 2108 of file RelAlgAbstractInterpreter.cpp.

References CHECK(), CHECK_EQ, and field().

2108  {
2109  const auto& table_json = field(scan_ra, "table");
2110  CHECK(table_json.IsArray());
2111  CHECK_EQ(unsigned(2), table_json.Size());
2112  const auto td = cat_.getMetadataForTable(table_json[1].GetString());
2113  CHECK(td);
2114  return td;
2115  }
#define CHECK_EQ(x, y)
Definition: Logger.h:198
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
CHECK(cgen_state)
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.

+ Here is the call graph for this function:

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

Definition at line 2136 of file RelAlgAbstractInterpreter.cpp.

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

2136  {
2137  const auto id = node_id(crt_node);
2138  CHECK(id);
2139  CHECK_EQ(static_cast<size_t>(id), nodes_.size());
2140  return nodes_.back();
2141  }
#define CHECK_EQ(x, y)
Definition: Logger.h:198
unsigned node_id(const rapidjson::Value &ra_node) noexcept
CHECK(cgen_state)

+ Here is the call graph for this function:

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

Definition at line 1798 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(), anonymous_namespace{RelAlgAbstractInterpreter.cpp}::separate_window_function_expressions(), simplify_sort(), and sink_projected_boolean_expr_to_join().

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

1798  {
1799  const auto& rels = field(query_ast_, "rels");
1800  CHECK(rels.IsArray());
1801  try {
1802  dispatchNodes(rels);
1803  } catch (const QueryNotSupported&) {
1804  throw;
1805  }
1806  CHECK(!nodes_.empty());
1808 
1809  if (render_opts_) {
1810  // Alter the RA for render. Do this before any flattening/optimizations are done to
1811  // the tree.
1813  }
1814 
1815  mark_nops(nodes_);
1820  std::vector<const RelAlgNode*> filtered_left_deep_joins;
1821  std::vector<const RelAlgNode*> left_deep_joins;
1822  for (const auto& node : nodes_) {
1823  const auto left_deep_join_root = get_left_deep_join_root(node);
1824  // The filter which starts a left-deep join pattern must not be coalesced
1825  // since it contains (part of) the join condition.
1826  if (left_deep_join_root) {
1827  left_deep_joins.push_back(left_deep_join_root.get());
1828  if (std::dynamic_pointer_cast<const RelFilter>(left_deep_join_root)) {
1829  filtered_left_deep_joins.push_back(left_deep_join_root.get());
1830  }
1831  }
1832  }
1833  if (filtered_left_deep_joins.empty()) {
1835  }
1836  eliminate_dead_columns(nodes_);
1838  coalesce_nodes(nodes_, left_deep_joins);
1839  CHECK(nodes_.back().unique());
1840  create_left_deep_join(nodes_);
1841  return nodes_.back();
1842  }
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
CHECK(cgen_state)
void bind_inputs(const std::vector< std::shared_ptr< RelAlgNode >> &nodes) noexcept
void separate_window_function_expressions(std::vector< std::shared_ptr< RelAlgNode >> &nodes)
void coalesce_nodes(std::vector< std::shared_ptr< RelAlgNode >> &nodes, const std::vector< const RelAlgNode * > &left_deep_joins)
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

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

Definition at line 2144 of file RelAlgAbstractInterpreter.cpp.

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

Definition at line 2145 of file RelAlgAbstractInterpreter.cpp.

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

Definition at line 2143 of file RelAlgAbstractInterpreter.cpp.

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

Definition at line 2146 of file RelAlgAbstractInterpreter.cpp.

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

Definition at line 2147 of file RelAlgAbstractInterpreter.cpp.


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