OmniSciDB  2e3a973ef4
SerializeToSql.h File Reference
+ Include dependency graph for SerializeToSql.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  ScalarExprToSql
 
struct  ExecutionUnitSql
 

Functions

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

◆ serialize_column_ref()

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

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

330  {
331  if (table_id >= 0) {
332  const auto cd = catalog->getMetadataForColumn(table_id, column_id);
333  CHECK(cd);
334  return cd->columnName;
335  }
336  return "col" + std::to_string(column_id);
337 }
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
std::string to_string(char const *&&v)
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize_table_ref()

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

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

319  {
320  if (table_id >= 0) {
321  const auto td = catalog->getMetadataForTable(table_id);
322  CHECK(td);
323  return td->tableName;
324  }
325  return "\"#temp" + std::to_string(table_id) + "\"";
326 }
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
std::string to_string(char const *&&v)
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize_to_sql()

ExecutionUnitSql serialize_to_sql ( const RelAlgExecutionUnit ra_exe_unit,
const Catalog_Namespace::Catalog catalog 
)

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

340  {
341  const auto targets = targets_to_string(ra_exe_unit, catalog);
342  const auto from = from_to_string(ra_exe_unit, catalog);
343  const auto join_on = join_condition_to_string(ra_exe_unit, catalog);
344  const auto where = where_to_string(ra_exe_unit, catalog);
345  const auto group = group_by_to_string(ra_exe_unit, catalog);
346  return {"SELECT " + targets + " FROM " + from + maybe("ON", join_on) +
347  maybe("WHERE", where) + maybe("GROUP BY", group),
348  from};
349 }
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: