OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{SerializeToSql.cpp} Namespace Reference

Functions

std::string agg_to_string (const Analyzer::AggExpr *agg_expr, const RelAlgExecutionUnit *ra_exe_unit)
 
std::string where_to_string (const RelAlgExecutionUnit *ra_exe_unit)
 
std::string join_condition_to_string (const RelAlgExecutionUnit *ra_exe_unit)
 
std::string targets_to_string (const RelAlgExecutionUnit *ra_exe_unit)
 
std::string group_by_to_string (const RelAlgExecutionUnit *ra_exe_unit)
 
std::string from_to_string (const RelAlgExecutionUnit *ra_exe_unit)
 
std::string maybe (const std::string &prefix, const std::string &clause)
 

Function Documentation

std::string anonymous_namespace{SerializeToSql.cpp}::agg_to_string ( const Analyzer::AggExpr agg_expr,
const RelAlgExecutionUnit ra_exe_unit 
)

Definition at line 120 of file SerializeToSql.cpp.

References Analyzer::AggExpr::get_aggtype(), Analyzer::AggExpr::get_arg(), Analyzer::AggExpr::get_is_distinct(), toString(), and ScalarExprVisitor< T >::visit().

Referenced by ScalarExprToSql::visitAggExpr().

121  {
122  ScalarExprToSql scalar_expr_to_sql(ra_exe_unit);
123  const auto agg_type = ::toString(agg_expr->get_aggtype());
124  const auto arg =
125  agg_expr->get_arg() ? scalar_expr_to_sql.visit(agg_expr->get_arg()) : "*";
126  const auto distinct = agg_expr->get_is_distinct() ? "DISTINCT " : "";
127  return agg_type + "(" + distinct + arg + ")";
128 }
Expr * get_arg() const
Definition: Analyzer.h:1330
std::string toString(const QueryDescriptionType &type)
Definition: Types.h:64
bool get_is_distinct() const
Definition: Analyzer.h:1332
SQLAgg get_aggtype() const
Definition: Analyzer.h:1329

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string anonymous_namespace{SerializeToSql.cpp}::from_to_string ( const RelAlgExecutionUnit ra_exe_unit)

Definition at line 274 of file SerializeToSql.cpp.

References Catalog_Namespace::SysCatalog::getCatalog(), RelAlgExecutionUnit::input_descs, Catalog_Namespace::SysCatalog::instance(), join(), and serialize_table_ref().

Referenced by serialize_to_sql().

274  {
275  std::vector<std::string> from_strings;
276  for (const auto& input_desc : ra_exe_unit->input_descs) {
277  const auto& table_key = input_desc.getTableKey();
278  const auto catalog =
280  const auto table_ref = serialize_table_ref(table_key.table_id, catalog.get());
281  from_strings.push_back(table_ref);
282  }
283  return boost::algorithm::join(from_strings, ", ");
284 }
std::string join(T const &container, std::string const &delim)
std::vector< InputDescriptor > input_descs
static SysCatalog & instance()
Definition: SysCatalog.h:343
std::shared_ptr< Catalog > getCatalog(const std::string &dbName)
std::string serialize_table_ref(const int table_id, const Catalog_Namespace::Catalog *catalog)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string anonymous_namespace{SerializeToSql.cpp}::group_by_to_string ( const RelAlgExecutionUnit ra_exe_unit)

Definition at line 265 of file SerializeToSql.cpp.

References RelAlgExecutionUnit::groupby_exprs, join(), and ScalarExprToSql::visitList().

Referenced by serialize_to_sql().

265  {
266  if (ra_exe_unit->groupby_exprs.size() == 1 || !ra_exe_unit->groupby_exprs.front()) {
267  return "";
268  }
269  ScalarExprToSql scalar_expr_to_sql(ra_exe_unit);
270  const auto group_by_strings = scalar_expr_to_sql.visitList(ra_exe_unit->groupby_exprs);
271  return boost::algorithm::join(group_by_strings, ", ");
272 }
std::string join(T const &container, std::string const &delim)
const std::list< std::shared_ptr< Analyzer::Expr > > groupby_exprs

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string anonymous_namespace{SerializeToSql.cpp}::join_condition_to_string ( const RelAlgExecutionUnit ra_exe_unit)

Definition at line 245 of file SerializeToSql.cpp.

References join(), RelAlgExecutionUnit::join_quals, and ScalarExprToSql::visitList().

Referenced by serialize_to_sql().

245  {
246  ScalarExprToSql scalar_expr_to_sql(ra_exe_unit);
247  std::vector<std::string> qual_strings;
248  for (const auto& join_level_quals : ra_exe_unit->join_quals) {
249  const auto level_qual_strings = scalar_expr_to_sql.visitList(join_level_quals.quals);
250  qual_strings.insert(
251  qual_strings.end(), level_qual_strings.begin(), level_qual_strings.end());
252  }
253  return boost::algorithm::join(qual_strings, " AND ");
254 }
std::string join(T const &container, std::string const &delim)
const JoinQualsPerNestingLevel join_quals

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string anonymous_namespace{SerializeToSql.cpp}::maybe ( const std::string &  prefix,
const std::string &  clause 
)

Definition at line 286 of file SerializeToSql.cpp.

Referenced by serialize_to_sql().

286  {
287  return clause.empty() ? "" : " " + prefix + " " + clause;
288 }

+ Here is the caller graph for this function:

std::string anonymous_namespace{SerializeToSql.cpp}::targets_to_string ( const RelAlgExecutionUnit ra_exe_unit)

Definition at line 256 of file SerializeToSql.cpp.

References join(), RelAlgExecutionUnit::target_exprs, and ScalarExprVisitor< T >::visit().

Referenced by serialize_to_sql().

256  {
257  ScalarExprToSql scalar_expr_to_sql(ra_exe_unit);
258  std::vector<std::string> target_strings;
259  for (const auto target : ra_exe_unit->target_exprs) {
260  target_strings.push_back(scalar_expr_to_sql.visit(target));
261  }
262  return boost::algorithm::join(target_strings, ", ");
263 }
std::vector< Analyzer::Expr * > target_exprs
std::string join(T const &container, std::string const &delim)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string anonymous_namespace{SerializeToSql.cpp}::where_to_string ( const RelAlgExecutionUnit ra_exe_unit)

Definition at line 235 of file SerializeToSql.cpp.

References join(), RelAlgExecutionUnit::quals, RelAlgExecutionUnit::simple_quals, and ScalarExprToSql::visitList().

Referenced by serialize_to_sql().

235  {
236  ScalarExprToSql scalar_expr_to_sql(ra_exe_unit);
237  auto qual_strings = scalar_expr_to_sql.visitList(ra_exe_unit->quals);
238  const auto simple_qual_strings =
239  scalar_expr_to_sql.visitList(ra_exe_unit->simple_quals);
240  qual_strings.insert(
241  qual_strings.end(), simple_qual_strings.begin(), simple_qual_strings.end());
242  return boost::algorithm::join(qual_strings, " AND ");
243 }
std::string join(T const &container, std::string const &delim)
std::list< std::shared_ptr< Analyzer::Expr > > quals
std::list< std::shared_ptr< Analyzer::Expr > > simple_quals

+ Here is the call graph for this function:

+ Here is the caller graph for this function: