OmniSciDB  21ac014ffc
 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, const Catalog_Namespace::Catalog *catalog)
 
std::string anonymous_namespace{SerializeToSql.cpp}::where_to_string (const RelAlgExecutionUnit *ra_exe_unit, const Catalog_Namespace::Catalog *catalog)
 
std::string anonymous_namespace{SerializeToSql.cpp}::join_condition_to_string (const RelAlgExecutionUnit *ra_exe_unit, const Catalog_Namespace::Catalog *catalog)
 
std::string anonymous_namespace{SerializeToSql.cpp}::targets_to_string (const RelAlgExecutionUnit *ra_exe_unit, const Catalog_Namespace::Catalog *catalog)
 
std::string anonymous_namespace{SerializeToSql.cpp}::group_by_to_string (const RelAlgExecutionUnit *ra_exe_unit, const Catalog_Namespace::Catalog *catalog)
 
std::string anonymous_namespace{SerializeToSql.cpp}::from_to_string (const RelAlgExecutionUnit *ra_exe_unit, const Catalog_Namespace::Catalog *catalog)
 
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, const Catalog_Namespace::Catalog *catalog)
 

Function Documentation

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

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

306  {
307  if (table_id >= 0) {
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:206

+ 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 294 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().

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

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().

316  {
317  const auto targets = targets_to_string(ra_exe_unit, catalog);
318  const auto from = from_to_string(ra_exe_unit, catalog);
319  const auto join_on = join_condition_to_string(ra_exe_unit, catalog);
320  const auto where = where_to_string(ra_exe_unit, catalog);
321  const auto group = group_by_to_string(ra_exe_unit, catalog);
322  return {"SELECT " + targets + " FROM " + from + maybe("ON", join_on) +
323  maybe("WHERE", where) + maybe("GROUP BY", group),
324  from};
325 }
std::string maybe(const std::string &prefix, const std::string &clause)
std::string from_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 targets_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 where_to_string(const RelAlgExecutionUnit *ra_exe_unit, const Catalog_Namespace::Catalog *catalog)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: