OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ShowModelsCommand Class Reference

#include <DdlCommandExecutor.h>

+ Inheritance diagram for ShowModelsCommand:
+ Collaboration diagram for ShowModelsCommand:

Public Member Functions

 ShowModelsCommand (const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
 
ExecutionResult execute (bool read_only_mode) override
 
- Public Member Functions inherited from DdlCommand
 DdlCommand (const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
 

Additional Inherited Members

- Protected Attributes inherited from DdlCommand
const DdlCommandDataddl_data_
 
std::shared_ptr
< Catalog_Namespace::SessionInfo
const > 
session_ptr_
 

Detailed Description

Definition at line 272 of file DdlCommandExecutor.h.

Constructor & Destructor Documentation

ShowModelsCommand::ShowModelsCommand ( const DdlCommandData ddl_data,
std::shared_ptr< Catalog_Namespace::SessionInfo const >  session_ptr 
)

Definition at line 2050 of file DdlCommandExecutor.cpp.

References g_enable_ml_functions, and g_restrict_ml_model_metadata_to_superusers.

2053  : DdlCommand(ddl_data, session_ptr) {
2054  if (!g_enable_ml_functions) {
2055  throw std::runtime_error("Cannot show models. ML functions are disabled.");
2056  }
2058  // Check if user is super user
2059  const auto& current_user = session_ptr->get_currentUser();
2060  if (!current_user.isSuper) {
2061  throw std::runtime_error(
2062  "Cannot show models. Showing model information to non-superusers is disabled.");
2063  }
2064  }
2065 }
bool g_restrict_ml_model_metadata_to_superusers
Definition: Execute.cpp:123
bool g_enable_ml_functions
Definition: Execute.cpp:122
DdlCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)

Member Function Documentation

ExecutionResult ShowModelsCommand::execute ( bool  read_only_mode)
overridevirtual

Executes the DDL command corresponding to provided JSON payload.

Parameters
_returnresult of DDL command execution (if applicable)

Implements DdlCommand.

Definition at line 2067 of file DdlCommandExecutor.cpp.

References ResultSetLogicalValuesBuilder::create(), g_ml_models, genLiteralStr(), legacylockmgr::getExecuteReadLock(), MLModelMap::getModelNames(), kTEXT, and run_benchmark_import::label.

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

2067  {
2068  auto execute_read_lock = legacylockmgr::getExecuteReadLock();
2069 
2070  // label_infos -> column labels
2071  std::vector<std::string> labels{"model_name"};
2072  std::vector<TargetMetaInfo> label_infos;
2073  for (const auto& label : labels) {
2074  label_infos.emplace_back(label, SQLTypeInfo(kTEXT, true));
2075  }
2076 
2077  // Get all model names
2078  const auto model_names = g_ml_models.getModelNames();
2079 
2080  // logical_values -> table data
2081  std::vector<RelLogicalValues::RowValues> logical_values;
2082  for (auto model_name : model_names) {
2083  logical_values.emplace_back(RelLogicalValues::RowValues{});
2084  logical_values.back().emplace_back(genLiteralStr(model_name));
2085  }
2086 
2087  // Create ResultSet
2088  std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
2089  ResultSetLogicalValuesBuilder::create(label_infos, logical_values));
2090 
2091  return ExecutionResult(rSet, label_infos);
2092 }
auto getExecuteReadLock()
static ResultSet * create(std::vector< TargetMetaInfo > &label_infos, std::vector< RelLogicalValues::RowValues > &logical_values)
MLModelMap g_ml_models
Definition: MLModel.h:125
Definition: sqltypes.h:79
static std::unique_ptr< RexLiteral > genLiteralStr(std::string val)
Definition: DBHandler.cpp:7770
std::vector< std::string > getModelNames() const
Definition: MLModel.h:75
std::vector< std::unique_ptr< const RexScalar >> RowValues
Definition: RelAlgDag.h:2656

+ 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: