OmniSciDB  95562058bd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RefreshForeignTablesCommand Class Reference

#include <DdlCommandExecutor.h>

+ Inheritance diagram for RefreshForeignTablesCommand:
+ Collaboration diagram for RefreshForeignTablesCommand:

Public Member Functions

 RefreshForeignTablesCommand (const rapidjson::Value &ddl_payload, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
 
void execute (TQueryResult &_return) override
 
- Public Member Functions inherited from DdlCommand
 DdlCommand (const rapidjson::Value &ddl_payload, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
 

Additional Inherited Members

- Protected Member Functions inherited from DdlCommand
bool isDefaultServer (const std::string &server_name)
 
- Protected Attributes inherited from DdlCommand
const rapidjson::Value & ddl_payload_
 
std::shared_ptr
< Catalog_Namespace::SessionInfo
const > 
session_ptr_
 

Detailed Description

Definition at line 161 of file DdlCommandExecutor.h.

Constructor & Destructor Documentation

RefreshForeignTablesCommand::RefreshForeignTablesCommand ( const rapidjson::Value &  ddl_payload,
std::shared_ptr< Catalog_Namespace::SessionInfo const >  session_ptr 
)

Definition at line 800 of file DdlCommandExecutor.cpp.

References CHECK.

803  : DdlCommand(ddl_payload, session_ptr) {
804  CHECK(ddl_payload.HasMember("tableNames"));
805  CHECK(ddl_payload["tableNames"].IsArray());
806  for (auto const& tablename_def : ddl_payload["tableNames"].GetArray()) {
807  CHECK(tablename_def.IsString());
808  }
809 }
DdlCommand(const rapidjson::Value &ddl_payload, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
#define CHECK(condition)
Definition: Logger.h:197

Member Function Documentation

void RefreshForeignTablesCommand::execute ( TQueryResult &  _return)
overridevirtual

Executes the DDL command corresponding to provided JSON payload.

Parameters
_returnresult of DDL command execution (if applicable)

Implements DdlCommand.

Definition at line 811 of file DdlCommandExecutor.cpp.

References cat(), CHECK, DdlCommand::ddl_payload_, foreign_storage::OptionsContainer::options, foreign_storage::OptionsContainer::populateOptionsMap(), foreign_storage::refresh_foreign_table(), and DdlCommand::session_ptr_.

Referenced by omnisci.cursor.Cursor::executemany().

811  {
812  bool evict_cached_entries{false};
814  if (ddl_payload_.HasMember("options") && !ddl_payload_["options"].IsNull()) {
815  opt.populateOptionsMap(ddl_payload_["options"]);
816  for (const auto entry : opt.options) {
817  if (entry.first != "EVICT") {
818  throw std::runtime_error{
819  "Invalid option \"" + entry.first +
820  "\" provided for refresh command. Only \"EVICT\" option is supported."};
821  }
822  }
823  CHECK(opt.options.find("EVICT") != opt.options.end());
824 
825  if (boost::iequals(opt.options["EVICT"], "true") ||
826  boost::iequals(opt.options["EVICT"], "false")) {
827  if (boost::iequals(opt.options["EVICT"], "true")) {
828  evict_cached_entries = true;
829  }
830  } else {
831  throw std::runtime_error{
832  "Invalid value \"" + opt.options["EVICT"] +
833  "\" provided for EVICT option. Value must be either \"true\" or \"false\"."};
834  }
835  }
836 
837  auto& cat = session_ptr_->getCatalog();
838  for (const auto& table_name_json : ddl_payload_["tableNames"].GetArray()) {
839  std::string table_name = table_name_json.GetString();
840  foreign_storage::refresh_foreign_table(cat, table_name, evict_cached_entries);
841  }
842 }
std::map< std::string, std::string, std::less<> > options
std::string cat(Ts &&...args)
void populateOptionsMap(const rapidjson::Value &ddl_options)
void refresh_foreign_table(Catalog_Namespace::Catalog &catalog, const std::string &table_name, const bool evict_cached_entries)
#define CHECK(condition)
Definition: Logger.h:197
const rapidjson::Value & ddl_payload_
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following files: