OmniSciDB  2e3a973ef4
anonymous_namespace{SerializeToSql.cpp} Namespace Reference

Functions

std::string agg_type_to_string (const SQLAgg agg_type)
 
std::string agg_to_string (const Analyzer::AggExpr *agg_expr, const RelAlgExecutionUnit *ra_exe_unit, const Catalog_Namespace::Catalog *catalog)
 
std::string where_to_string (const RelAlgExecutionUnit *ra_exe_unit, const Catalog_Namespace::Catalog *catalog)
 
std::string join_condition_to_string (const RelAlgExecutionUnit *ra_exe_unit, const Catalog_Namespace::Catalog *catalog)
 
std::string targets_to_string (const RelAlgExecutionUnit *ra_exe_unit, const Catalog_Namespace::Catalog *catalog)
 
std::string group_by_to_string (const RelAlgExecutionUnit *ra_exe_unit, const Catalog_Namespace::Catalog *catalog)
 
std::string from_to_string (const RelAlgExecutionUnit *ra_exe_unit, const Catalog_Namespace::Catalog *catalog)
 
std::string maybe (const std::string &prefix, const std::string &clause)
 

Function Documentation

◆ agg_to_string()

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

Definition at line 143 of file SerializeToSql.cpp.

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

Referenced by ScalarExprToSql::visitAggExpr().

145  {
146  ScalarExprToSql scalar_expr_to_sql(ra_exe_unit, catalog);
147  const auto agg_type = agg_type_to_string(agg_expr->get_aggtype());
148  const auto arg =
149  agg_expr->get_arg() ? scalar_expr_to_sql.visit(agg_expr->get_arg()) : "*";
150  const auto distinct = agg_expr->get_is_distinct() ? "DISTINCT " : "";
151  return agg_type + "(" + distinct + arg + ")";
152 }
Expr * get_arg() const
Definition: Analyzer.h:1096
std::string agg_type_to_string(const SQLAgg agg_type)
SQLAgg get_aggtype() const
Definition: Analyzer.h:1095
bool get_is_distinct() const
Definition: Analyzer.h:1098
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ agg_type_to_string()

std::string anonymous_namespace{SerializeToSql.cpp}::agg_type_to_string ( const SQLAgg  agg_type)

Definition at line 121 of file SerializeToSql.cpp.

References logger::FATAL, kAPPROX_COUNT_DISTINCT, kAVG, kCOUNT, kMAX, kMIN, kSAMPLE, kSUM, and LOG.

Referenced by agg_to_string().

121  {
122  switch (agg_type) {
123  case kAVG:
124  return "AVG";
125  case kMIN:
126  return "MIN";
127  case kMAX:
128  return "MAX";
129  case kSUM:
130  return "SUM";
131  case kCOUNT:
132  return "COUNT";
134  return "APPROX_COUNT_DISTINCT";
135  case kSAMPLE:
136  return "SAMPLE";
137  default:
138  LOG(FATAL) << "Invalid aggregate type: " << agg_type;
139  return "";
140  }
141 }
#define LOG(tag)
Definition: Logger.h:188
Definition: sqldefs.h:73
Definition: sqldefs.h:75
Definition: sqldefs.h:76
Definition: sqldefs.h:74
Definition: sqldefs.h:72
+ Here is the caller graph for this function:

◆ from_to_string()

std::string anonymous_namespace{SerializeToSql.cpp}::from_to_string ( const RelAlgExecutionUnit ra_exe_unit,
const Catalog_Namespace::Catalog catalog 
)

Definition at line 302 of file SerializeToSql.cpp.

References RelAlgExecutionUnit::input_descs, join(), and serialize_table_ref().

Referenced by serialize_to_sql().

303  {
304  std::vector<std::string> from_strings;
305  for (const auto& input_desc : ra_exe_unit->input_descs) {
306  const auto table_ref = serialize_table_ref(input_desc.getTableId(), catalog);
307  from_strings.push_back(table_ref);
308  }
309  return boost::algorithm::join(from_strings, ", ");
310 }
std::string join(T const &container, std::string const &delim)
std::vector< InputDescriptor > input_descs
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:

◆ group_by_to_string()

std::string anonymous_namespace{SerializeToSql.cpp}::group_by_to_string ( const RelAlgExecutionUnit ra_exe_unit,
const Catalog_Namespace::Catalog catalog 
)

Definition at line 292 of file SerializeToSql.cpp.

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

Referenced by serialize_to_sql().

293  {
294  if (ra_exe_unit->groupby_exprs.size() == 1 || !ra_exe_unit->groupby_exprs.front()) {
295  return "";
296  }
297  ScalarExprToSql scalar_expr_to_sql(ra_exe_unit, catalog);
298  const auto group_by_strings = scalar_expr_to_sql.visitList(ra_exe_unit->groupby_exprs);
299  return boost::algorithm::join(group_by_strings, ", ");
300 }
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:

◆ join_condition_to_string()

std::string anonymous_namespace{SerializeToSql.cpp}::join_condition_to_string ( const RelAlgExecutionUnit ra_exe_unit,
const Catalog_Namespace::Catalog catalog 
)

Definition at line 270 of file SerializeToSql.cpp.

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

Referenced by serialize_to_sql().

271  {
272  ScalarExprToSql scalar_expr_to_sql(ra_exe_unit, catalog);
273  std::vector<std::string> qual_strings;
274  for (const auto& join_level_quals : ra_exe_unit->join_quals) {
275  const auto level_qual_strings = scalar_expr_to_sql.visitList(join_level_quals.quals);
276  qual_strings.insert(
277  qual_strings.end(), level_qual_strings.begin(), level_qual_strings.end());
278  }
279  return boost::algorithm::join(qual_strings, " AND ");
280 }
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:

◆ maybe()

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

Definition at line 312 of file SerializeToSql.cpp.

Referenced by serialize_to_sql().

312  {
313  return clause.empty() ? "" : " " + prefix + " " + clause;
314 }
+ Here is the caller graph for this function:

◆ targets_to_string()

std::string anonymous_namespace{SerializeToSql.cpp}::targets_to_string ( const RelAlgExecutionUnit ra_exe_unit,
const Catalog_Namespace::Catalog catalog 
)

Definition at line 282 of file SerializeToSql.cpp.

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

Referenced by serialize_to_sql().

283  {
284  ScalarExprToSql scalar_expr_to_sql(ra_exe_unit, catalog);
285  std::vector<std::string> target_strings;
286  for (const auto target : ra_exe_unit->target_exprs) {
287  target_strings.push_back(scalar_expr_to_sql.visit(target));
288  }
289  return boost::algorithm::join(target_strings, ", ");
290 }
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:

◆ where_to_string()

std::string anonymous_namespace{SerializeToSql.cpp}::where_to_string ( const RelAlgExecutionUnit ra_exe_unit,
const Catalog_Namespace::Catalog catalog 
)

Definition at line 259 of file SerializeToSql.cpp.

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

Referenced by serialize_to_sql().

260  {
261  ScalarExprToSql scalar_expr_to_sql(ra_exe_unit, catalog);
262  auto qual_strings = scalar_expr_to_sql.visitList(ra_exe_unit->quals);
263  const auto simple_qual_strings =
264  scalar_expr_to_sql.visitList(ra_exe_unit->simple_quals);
265  qual_strings.insert(
266  qual_strings.end(), simple_qual_strings.begin(), simple_qual_strings.end());
267  return boost::algorithm::join(qual_strings, " AND ");
268 }
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: