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

#include <DdlCommandExecutor.h>

+ Inheritance diagram for JsonColumnSqlType:
+ Collaboration diagram for JsonColumnSqlType:

Public Member Functions

 JsonColumnSqlType (const rapidjson::Value &data_type)
 
- Public Member Functions inherited from ddl_utils::SqlType
 SqlType (SQLTypes type, int param1, int param2, bool is_array, int array_size)
 
virtual SQLTypes get_type () const
 
virtual int get_param1 () const
 
virtual void set_param1 (int param)
 
virtual int get_param2 () const
 
virtual bool get_is_array () const
 
virtual void set_is_array (bool a)
 
virtual int get_array_size () const
 
virtual void set_array_size (int s)
 
virtual std::string to_string () const
 
virtual void check_type ()
 

Static Private Member Functions

static SQLTypes getSqlType (const rapidjson::Value &data_type)
 
static SQLTypes getSqlType (const std::string &type)
 
static int getParam1 (const rapidjson::Value &data_type)
 
static int getParam2 (const rapidjson::Value &data_type)
 
static bool isArray (const rapidjson::Value &data_type)
 
static int getArraySize (const rapidjson::Value &data_type)
 

Additional Inherited Members

- Protected Attributes inherited from ddl_utils::SqlType
SQLTypes type
 
int param1
 
int param2
 
bool is_array
 
int array_size
 

Detailed Description

Definition at line 85 of file DdlCommandExecutor.h.

Constructor & Destructor Documentation

JsonColumnSqlType::JsonColumnSqlType ( const rapidjson::Value &  data_type)
inline

Definition at line 87 of file DdlCommandExecutor.h.

88  : ddl_utils::SqlType(getSqlType(data_type),
89  getParam1(data_type),
90  getParam2(data_type),
91  isArray(data_type),
92  getArraySize(data_type)) {}
static int getParam2(const rapidjson::Value &data_type)
static bool isArray(const rapidjson::Value &data_type)
static int getArraySize(const rapidjson::Value &data_type)
static SQLTypes getSqlType(const rapidjson::Value &data_type)
static int getParam1(const rapidjson::Value &data_type)

Member Function Documentation

int JsonColumnSqlType::getArraySize ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 476 of file DdlCommandExecutor.cpp.

References CHECK, and isArray().

476  {
477  int size = -1;
478  if (isArray(data_type)) {
479  CHECK(data_type.HasMember("array"));
480  CHECK(data_type["array"].IsObject());
481 
482  const auto& array = data_type["array"].GetObject();
483  if (array.HasMember("size") && !array["size"].IsNull()) {
484  CHECK(array["size"].IsInt());
485  size = array["size"].GetInt();
486  }
487  }
488  return size;
489 }
static bool isArray(const rapidjson::Value &data_type)
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

int JsonColumnSqlType::getParam1 ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 442 of file DdlCommandExecutor.cpp.

References CHECK, getSqlType(), IS_GEO, kGEOMETRY, ddl_utils::SqlType::param1, and ddl_utils::SqlType::type.

442  {
443  int param1 = -1;
444  CHECK(data_type.IsObject());
445  if (data_type.HasMember("precision") && !data_type["precision"].IsNull()) {
446  CHECK(data_type["precision"].IsInt());
447  param1 = data_type["precision"].GetInt();
448  } else if (auto type = getSqlType(data_type); IS_GEO(type)) {
449  param1 = static_cast<int>(kGEOMETRY);
450  }
451  return param1;
452 }
SQLTypes type
Definition: DdlUtils.h:54
#define CHECK(condition)
Definition: Logger.h:197
static SQLTypes getSqlType(const rapidjson::Value &data_type)
#define IS_GEO(T)
Definition: sqltypes.h:174

+ Here is the call graph for this function:

int JsonColumnSqlType::getParam2 ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 454 of file DdlCommandExecutor.cpp.

References CHECK, getSqlType(), IS_GEO, ddl_utils::SqlType::param2, and ddl_utils::SqlType::type.

454  {
455  int param2 = 0;
456  CHECK(data_type.IsObject());
457  if (data_type.HasMember("scale") && !data_type["scale"].IsNull()) {
458  CHECK(data_type["scale"].IsInt());
459  param2 = data_type["scale"].GetInt();
460  } else if (auto type = getSqlType(data_type); IS_GEO(type) &&
461  data_type.HasMember("coordinateSystem") &&
462  !data_type["coordinateSystem"].IsNull()) {
463  CHECK(data_type["coordinateSystem"].IsInt());
464  param2 = data_type["coordinateSystem"].GetInt();
465  }
466  return param2;
467 }
SQLTypes type
Definition: DdlUtils.h:54
#define CHECK(condition)
Definition: Logger.h:197
static SQLTypes getSqlType(const rapidjson::Value &data_type)
#define IS_GEO(T)
Definition: sqltypes.h:174

+ Here is the call graph for this function:

SQLTypes JsonColumnSqlType::getSqlType ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 371 of file DdlCommandExecutor.cpp.

References CHECK, and ddl_utils::SqlType::type.

Referenced by getParam1(), and getParam2().

371  {
372  CHECK(data_type.IsObject());
373  CHECK(data_type.HasMember("type"));
374  CHECK(data_type["type"].IsString());
375 
376  std::string type = data_type["type"].GetString();
377  if (boost::iequals(type, "ARRAY")) {
378  CHECK(data_type.HasMember("array"));
379  CHECK(data_type["array"].IsObject());
380 
381  const auto& array = data_type["array"].GetObject();
382  CHECK(array.HasMember("elementType"));
383  CHECK(array["elementType"].IsString());
384  type = array["elementType"].GetString();
385  }
386  return getSqlType(type);
387 }
SQLTypes type
Definition: DdlUtils.h:54
#define CHECK(condition)
Definition: Logger.h:197
static SQLTypes getSqlType(const rapidjson::Value &data_type)

+ Here is the caller graph for this function:

SQLTypes JsonColumnSqlType::getSqlType ( const std::string &  type)
staticprivate

Definition at line 389 of file DdlCommandExecutor.cpp.

References kBIGINT, kBOOLEAN, kDATE, kDECIMAL, kDOUBLE, kFLOAT, kINT, kLINESTRING, kMULTIPOLYGON, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, and kTINYINT.

389  {
390  if (boost::iequals(type, "BIGINT")) {
391  return kBIGINT;
392  }
393  if (boost::iequals(type, "BOOLEAN")) {
394  return kBOOLEAN;
395  }
396  if (boost::iequals(type, "DATE")) {
397  return kDATE;
398  }
399  if (boost::iequals(type, "DECIMAL")) {
400  return kDECIMAL;
401  }
402  if (boost::iequals(type, "DOUBLE")) {
403  return kDOUBLE;
404  }
405  if (boost::iequals(type, "FLOAT")) {
406  return kFLOAT;
407  }
408  if (boost::iequals(type, "INTEGER")) {
409  return kINT;
410  }
411  if (boost::iequals(type, "LINESTRING")) {
412  return kLINESTRING;
413  }
414  if (boost::iequals(type, "MULTIPOLYGON")) {
415  return kMULTIPOLYGON;
416  }
417  if (boost::iequals(type, "POINT")) {
418  return kPOINT;
419  }
420  if (boost::iequals(type, "POLYGON")) {
421  return kPOLYGON;
422  }
423  if (boost::iequals(type, "SMALLINT")) {
424  return kSMALLINT;
425  }
426  if (boost::iequals(type, "TEXT")) {
427  return kTEXT;
428  }
429  if (boost::iequals(type, "TIME")) {
430  return kTIME;
431  }
432  if (boost::iequals(type, "TIMESTAMP")) {
433  return kTIMESTAMP;
434  }
435  if (boost::iequals(type, "TINYINT")) {
436  return kTINYINT;
437  }
438 
439  throw std::runtime_error{"Unsupported type \"" + type + "\" specified."};
440 }
Definition: sqltypes.h:51
SQLTypes type
Definition: DdlUtils.h:54
Definition: sqltypes.h:54
Definition: sqltypes.h:55
Definition: sqltypes.h:47
bool JsonColumnSqlType::isArray ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 469 of file DdlCommandExecutor.cpp.

References CHECK.

Referenced by getArraySize().

469  {
470  CHECK(data_type.IsObject());
471  CHECK(data_type.HasMember("type"));
472  CHECK(data_type["type"].IsString());
473  return boost::iequals(data_type["type"].GetString(), "ARRAY");
474 }
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the caller graph for this function:


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