OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SerializeToSql.cpp File Reference
#include "SerializeToSql.h"
#include "ExternalExecutor.h"
+ Include dependency graph for SerializeToSql.cpp:

Go to the source code of this file.

Namespaces

 anonymous_namespace{SerializeToSql.cpp}
 

Functions

std::string anonymous_namespace{SerializeToSql.cpp}::agg_to_string (const Analyzer::AggExpr *agg_expr, const RelAlgExecutionUnit *ra_exe_unit)
 
std::string anonymous_namespace{SerializeToSql.cpp}::where_to_string (const RelAlgExecutionUnit *ra_exe_unit)
 
std::string anonymous_namespace{SerializeToSql.cpp}::join_condition_to_string (const RelAlgExecutionUnit *ra_exe_unit)
 
std::string anonymous_namespace{SerializeToSql.cpp}::targets_to_string (const RelAlgExecutionUnit *ra_exe_unit)
 
std::string anonymous_namespace{SerializeToSql.cpp}::group_by_to_string (const RelAlgExecutionUnit *ra_exe_unit)
 
std::string anonymous_namespace{SerializeToSql.cpp}::from_to_string (const RelAlgExecutionUnit *ra_exe_unit)
 
std::string anonymous_namespace{SerializeToSql.cpp}::maybe (const std::string &prefix, const std::string &clause)
 
std::string serialize_table_ref (const int table_id, const Catalog_Namespace::Catalog *catalog)
 
std::string serialize_column_ref (const int table_id, const int column_id, const Catalog_Namespace::Catalog *catalog)
 
ExecutionUnitSql serialize_to_sql (const RelAlgExecutionUnit *ra_exe_unit)
 

Function Documentation

std::string serialize_column_ref ( const int  table_id,
const int  column_id,
const Catalog_Namespace::Catalog catalog 
)

Definition at line 303 of file SerializeToSql.cpp.

References CHECK, Catalog_Namespace::Catalog::getMetadataForColumn(), and to_string().

Referenced by anonymous_namespace{ExternalExecutor.cpp}::create_table_schema(), and ScalarExprToSql::visitColumnVar().

305  {
306  if (table_id >= 0) {
307  CHECK(catalog);
308  const auto cd = catalog->getMetadataForColumn(table_id, column_id);
309  CHECK(cd);
310  return cd->columnName;
311  }
312  return "col" + std::to_string(column_id);
313 }
std::string to_string(char const *&&v)
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string serialize_table_ref ( const int  table_id,
const Catalog_Namespace::Catalog catalog 
)

Definition at line 292 of file SerializeToSql.cpp.

References CHECK, Catalog_Namespace::Catalog::getMetadataForTable(), and to_string().

Referenced by anonymous_namespace{SerializeToSql.cpp}::from_to_string(), and ScalarExprToSql::visitColumnVar().

293  {
294  if (table_id >= 0) {
295  CHECK(catalog);
296  const auto td = catalog->getMetadataForTable(table_id);
297  CHECK(td);
298  return td->tableName;
299  }
300  return "\"#temp" + std::to_string(table_id) + "\"";
301 }
std::string to_string(char const *&&v)
#define CHECK(condition)
Definition: Logger.h:291
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:

+ Here is the caller graph for this function:

ExecutionUnitSql serialize_to_sql ( const RelAlgExecutionUnit ra_exe_unit)

Definition at line 315 of file SerializeToSql.cpp.

References anonymous_namespace{SerializeToSql.cpp}::from_to_string(), anonymous_namespace{SerializeToSql.cpp}::group_by_to_string(), anonymous_namespace{SerializeToSql.cpp}::join_condition_to_string(), anonymous_namespace{SerializeToSql.cpp}::maybe(), anonymous_namespace{SerializeToSql.cpp}::targets_to_string(), and anonymous_namespace{SerializeToSql.cpp}::where_to_string().

Referenced by ExecutionKernel::runImpl().

315  {
316  const auto targets = targets_to_string(ra_exe_unit);
317  const auto from = from_to_string(ra_exe_unit);
318  const auto join_on = join_condition_to_string(ra_exe_unit);
319  const auto where = where_to_string(ra_exe_unit);
320  const auto group = group_by_to_string(ra_exe_unit);
321  return {"SELECT " + targets + " FROM " + from + maybe("ON", join_on) +
322  maybe("WHERE", where) + maybe("GROUP BY", group),
323  from};
324 }
std::string join_condition_to_string(const RelAlgExecutionUnit *ra_exe_unit)
std::string group_by_to_string(const RelAlgExecutionUnit *ra_exe_unit)
std::string maybe(const std::string &prefix, const std::string &clause)
std::string targets_to_string(const RelAlgExecutionUnit *ra_exe_unit)
std::string from_to_string(const RelAlgExecutionUnit *ra_exe_unit)
std::string where_to_string(const RelAlgExecutionUnit *ra_exe_unit)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: