OmniSciDB  04ee39c94c
CtasIntegrationTest.cpp File Reference
#include <gtest/gtest.h>
#include <boost/program_options.hpp>
#include <thrift/Thrift.h>
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/protocol/TJSONProtocol.h>
#include <thrift/transport/TBufferTransports.h>
#include <thrift/transport/TSocket.h>
#include "QueryEngine/TargetValue.h"
#include "Shared/ThriftClient.h"
#include "Shared/sqltypes.h"
#include "TestHelpers.h"
#include "gen-cpp/MapD.h"
#include <ctime>
#include <iostream>
+ Include dependency graph for CtasIntegrationTest.cpp:

Go to the source code of this file.

Classes

class  TestColumnDescriptor
 
class  NumberColumnDescriptor< T >
 
class  BooleanColumnDescriptor
 
class  StringColumnDescriptor
 
class  DateTimeColumnDescriptor
 
class  ArrayColumnDescriptor
 
class  GeoPointColumnDescriptor
 
class  GeoLinestringColumnDescriptor
 
class  GeoMultiPolygonColumnDescriptor
 
class  GeoPolygonColumnDescriptor
 
struct  Ctas
 
struct  Itas
 
struct  Update
 

Macros

#define INSTANTIATE_DATA_INGESTION_TEST(CDT)
 
#define BOOLEAN_COLUMN_TEST(name, c_type, definition, sql_type, null)
 
#define NUMBER_COLUMN_TEST(name, c_type, definition, sql_type, null)
 
#define STRING_COLUMN_TEST(name, definition, sql_type)
 
#define TIME_COLUMN_TEST(name, definition, sql_type, format, offset, scale)
 
#define ARRAY_COLUMN_TEST(name, definition)
 

Functions

template<typename RETURN_TYPE , typename SOURCE_TYPE >
bool checked_get (size_t row, const SOURCE_TYPE *boost_variant, RETURN_TYPE &val, RETURN_TYPE null_value)
 
template<>
bool checked_get (size_t row, const ScalarTargetValue *boost_variant, std::string &val, std::string null_value)
 
template<>
bool checked_get (size_t row, const TDatum *datum, int64_t &val, int64_t null_value)
 
template<>
bool checked_get (size_t row, const TDatum *datum, float &val, float null_value)
 
template<>
bool checked_get (size_t row, const TDatum *datum, double &val, double null_value)
 
template<>
bool checked_get (size_t row, const TDatum *datum, std::string &val, std::string null_value)
 
TQueryResult run_multiple_agg (std::string sql)
 
void run_ddl_statement (std::string ddl)
 
 TEST (Ctas, SyntaxCheck)
 
 TEST_P (Ctas, CreateTableAsSelect)
 
void itasTestBody (std::vector< std::shared_ptr< TestColumnDescriptor >> &columnDescriptors, std::string targetPartitionScheme=")")
 
 TEST_P (Itas, InsertIntoTableFromSelect)
 
 TEST_P (Itas, InsertIntoTableFromSelectReplicated)
 
 TEST_P (Itas, InsertIntoTableFromSelectSharded)
 
 BOOLEAN_COLUMN_TEST (BOOLEAN, int64_t, "BOOLEAN", kBOOLEAN, NULL_TINYINT)
 
 ARRAY_COLUMN_TEST (BOOLEAN, "BOOLEAN")
 
 NUMBER_COLUMN_TEST (TINYINT, int64_t, "TINYINT", kTINYINT, NULL_TINYINT)
 
 ARRAY_COLUMN_TEST (TINYINT, "TINYINT")
 
 NUMBER_COLUMN_TEST (SMALLINT, int64_t, "SMALLINT", kSMALLINT, NULL_SMALLINT)
 
 NUMBER_COLUMN_TEST (SMALLINT_8, int64_t, "SMALLINT ENCODING FIXED(8)", kSMALLINT, NULL_SMALLINT)
 
 ARRAY_COLUMN_TEST (SMALLINT, "SMALLINT")
 
 NUMBER_COLUMN_TEST (INTEGER, int64_t, "INTEGER", kINT, NULL_INT)
 
 NUMBER_COLUMN_TEST (INTEGER_8, int64_t, "INTEGER ENCODING FIXED(8)", kINT, NULL_INT)
 
 NUMBER_COLUMN_TEST (INTEGER_16, int64_t, "INTEGER ENCODING FIXED(16)", kINT, NULL_INT)
 
 ARRAY_COLUMN_TEST (INTEGER, "INTEGER")
 
 NUMBER_COLUMN_TEST (BIGINT, int64_t, "BIGINT", kBIGINT, NULL_BIGINT)
 
 NUMBER_COLUMN_TEST (BIGINT_8, int64_t, "BIGINT ENCODING FIXED(8)", kBIGINT, NULL_BIGINT)
 
 NUMBER_COLUMN_TEST (BIGINT_16, int64_t, "BIGINT ENCODING FIXED(16)", kBIGINT, NULL_BIGINT)
 
 NUMBER_COLUMN_TEST (BIGINT_32, int64_t, "BIGINT ENCODING FIXED(32)", kBIGINT, NULL_BIGINT)
 
 ARRAY_COLUMN_TEST (BIGINT, "BIGINT")
 
 NUMBER_COLUMN_TEST (FLOAT, float, "FLOAT", kFLOAT, NULL_FLOAT)
 
 ARRAY_COLUMN_TEST (FLOAT, "FLOAT")
 
 NUMBER_COLUMN_TEST (DOUBLE, double, "DOUBLE", kDOUBLE, NULL_DOUBLE)
 
 ARRAY_COLUMN_TEST (DOUBLE, "DOUBLE")
 
 NUMBER_COLUMN_TEST (NUMERIC, double, "NUMERIC(18)", kNUMERIC, NULL_DOUBLE)
 
 NUMBER_COLUMN_TEST (NUMERIC_32, double, "NUMERIC(9) ENCODING FIXED(32)", kNUMERIC, NULL_DOUBLE)
 
 NUMBER_COLUMN_TEST (NUMERIC_16, double, "NUMERIC(4) ENCODING FIXED(16)", kNUMERIC, NULL_DOUBLE)
 
 ARRAY_COLUMN_TEST (NUMERIC, "NUMERIC(18)")
 
 NUMBER_COLUMN_TEST (DECIMAL, double, "DECIMAL(18,9)", kDECIMAL, NULL_DOUBLE)
 
 NUMBER_COLUMN_TEST (DECIMAL_32, double, "DECIMAL(9,2) ENCODING FIXED(32)", kDECIMAL, NULL_DOUBLE)
 
 NUMBER_COLUMN_TEST (DECIMAL_16, double, "DECIMAL(4,2) ENCODING FIXED(16)", kDECIMAL, NULL_DOUBLE)
 
 ARRAY_COLUMN_TEST (DECIMAL, "DECIMAL(18,9)")
 
 STRING_COLUMN_TEST (CHAR, "CHAR(100)", kCHAR)
 
 STRING_COLUMN_TEST (CHAR_DICT, "CHAR(100) ENCODING DICT", kCHAR)
 
 STRING_COLUMN_TEST (CHAR_DICT_8, "CHAR(100) ENCODING DICT(8)", kCHAR)
 
 STRING_COLUMN_TEST (CHAR_DICT_16, "CHAR(100) ENCODING DICT(16)", kCHAR)
 
 STRING_COLUMN_TEST (CHAR_NONE, "CHAR(100) ENCODING NONE", kCHAR)
 
 ARRAY_COLUMN_TEST (CHAR, "CHAR(100)")
 
 STRING_COLUMN_TEST (VARCHAR, "VARCHAR(100)", kCHAR)
 
 STRING_COLUMN_TEST (VARCHAR_DICT, "VARCHAR(100) ENCODING DICT", kCHAR)
 
 STRING_COLUMN_TEST (VARCHAR_DICT_8, "VARCHAR(100) ENCODING DICT(8)", kCHAR)
 
 STRING_COLUMN_TEST (VARCHAR_DICT_16, "VARCHAR(100) ENCODING DICT(16)", kCHAR)
 
 STRING_COLUMN_TEST (VARCHAR_NONE, "VARCHAR(100) ENCODING NONE", kCHAR)
 
 ARRAY_COLUMN_TEST (VARCHAR, "VARCHAR(100)")
 
 STRING_COLUMN_TEST (TEXT, "TEXT", kTEXT)
 
 STRING_COLUMN_TEST (TEXT_DICT, "TEXT ENCODING DICT", kTEXT)
 
 STRING_COLUMN_TEST (TEXT_DICT_8, "TEXT ENCODING DICT(8)", kTEXT)
 
 STRING_COLUMN_TEST (TEXT_DICT_16, "TEXT ENCODING DICT(16)", kTEXT)
 
 STRING_COLUMN_TEST (TEXT_NONE, "TEXT ENCODING NONE", kTEXT)
 
 ARRAY_COLUMN_TEST (TEXT, "TEXT")
 
 TIME_COLUMN_TEST (TIME, "TIME", kTIME, "%T", 0, 1)
 
 TIME_COLUMN_TEST (TIME_32, "TIME ENCODING FIXED(32)", kTIME, "%T", 0, 1)
 
 ARRAY_COLUMN_TEST (TIME, "TIME")
 
 TIME_COLUMN_TEST (DATE, "DATE", kDATE, "%F", 0, 160 *60 *100)
 
 TIME_COLUMN_TEST (DATE_16, "DATE ENCODING FIXED(16)", kDATE, "%F", 0, 160 *60 *100)
 
 ARRAY_COLUMN_TEST (DATE, "DATE")
 
 TIME_COLUMN_TEST (TIMESTAMP, "TIMESTAMP", kTIMESTAMP, "%F %T", 0, 160 *60 *100)
 
 TIME_COLUMN_TEST (TIMESTAMP_32, "TIMESTAMP ENCODING FIXED(32)", kTIMESTAMP, "%F %T", 0, 160 *60 *100)
 
 ARRAY_COLUMN_TEST (TIMESTAMP, "TIMESTAMP")
 
 INSTANTIATE_DATA_INGESTION_TEST (GEO_POINT)
 
 INSTANTIATE_DATA_INGESTION_TEST (GEO_LINESTRING)
 
 INSTANTIATE_DATA_INGESTION_TEST (GEO_POLYGON)
 
 INSTANTIATE_DATA_INGESTION_TEST (GEO_MULTI_POLYGON)
 
 INSTANTIATE_TEST_CASE_P (MIXED_NO_GEO, Ctas, testing::Values(std::vector< std::shared_ptr< TestColumnDescriptor >>{BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, NUMERIC, DECIMAL, CHAR, VARCHAR, TEXT, TIME, DATE, TIMESTAMP}))
 
 INSTANTIATE_TEST_CASE_P (MIXED_NO_GEO, Itas, testing::Values(std::vector< std::shared_ptr< TestColumnDescriptor >>{BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, NUMERIC, DECIMAL, CHAR, VARCHAR, TEXT, TIME, DATE, TIMESTAMP}))
 
 INSTANTIATE_TEST_CASE_P (MIXED_WITH_GEO, Update, testing::Values(std::vector< std::shared_ptr< TestColumnDescriptor >>{TEXT, INTEGER, DOUBLE, GEO_POINT, GEO_LINESTRING, GEO_POLYGON, GEO_MULTI_POLYGON }))
 
int main (int argc, char *argv[])
 

Variables

TSessionId g_session_id
 
std::shared_ptr< MapDClient > g_client
 
const std::shared_ptr< TestColumnDescriptorSTRING_NONE_BASE
 
const std::shared_ptr< TestColumnDescriptorGEO_POINT
 
const std::shared_ptr< TestColumnDescriptorGEO_LINESTRING
 
const std::shared_ptr< TestColumnDescriptorGEO_POLYGON
 
const std::shared_ptr< TestColumnDescriptorGEO_MULTI_POLYGON
 

Macro Definition Documentation

◆ ARRAY_COLUMN_TEST

#define ARRAY_COLUMN_TEST (   name,
  definition 
)
Value:
const std::shared_ptr<TestColumnDescriptor> name##_ARRAY = \
std::make_shared<ArrayColumnDescriptor>(definition, name, 0); \
INSTANTIATE_DATA_INGESTION_TEST(name##_ARRAY); \
const std::shared_ptr<TestColumnDescriptor> name##_FIXED_LEN_ARRAY = \
std::make_shared<ArrayColumnDescriptor>(definition, name, 3); \
INSTANTIATE_DATA_INGESTION_TEST(name##_FIXED_LEN_ARRAY)

Definition at line 869 of file CtasIntegrationTest.cpp.

◆ BOOLEAN_COLUMN_TEST

#define BOOLEAN_COLUMN_TEST (   name,
  c_type,
  definition,
  sql_type,
  null 
)
Value:
const std::shared_ptr<TestColumnDescriptor> name = \
std::make_shared<BooleanColumnDescriptor>(definition, sql_type); \
INSTANTIATE_DATA_INGESTION_TEST(name)

Definition at line 848 of file CtasIntegrationTest.cpp.

◆ INSTANTIATE_DATA_INGESTION_TEST

#define INSTANTIATE_DATA_INGESTION_TEST (   CDT)

Definition at line 844 of file CtasIntegrationTest.cpp.

◆ NUMBER_COLUMN_TEST

#define NUMBER_COLUMN_TEST (   name,
  c_type,
  definition,
  sql_type,
  null 
)
Value:
const std::shared_ptr<TestColumnDescriptor> name = \
std::make_shared<NumberColumnDescriptor<c_type>>(definition, sql_type, null); \
INSTANTIATE_DATA_INGESTION_TEST(name)

Definition at line 853 of file CtasIntegrationTest.cpp.

◆ STRING_COLUMN_TEST

#define STRING_COLUMN_TEST (   name,
  definition,
  sql_type 
)
Value:
const std::shared_ptr<TestColumnDescriptor> name = \
std::make_shared<StringColumnDescriptor>(definition, sql_type, #name); \
INSTANTIATE_DATA_INGESTION_TEST(name)

Definition at line 858 of file CtasIntegrationTest.cpp.

◆ TIME_COLUMN_TEST

#define TIME_COLUMN_TEST (   name,
  definition,
  sql_type,
  format,
  offset,
  scale 
)
Value:
const std::shared_ptr<TestColumnDescriptor> name = \
std::make_shared<DateTimeColumnDescriptor>( \
definition, sql_type, format, offset, scale); \
INSTANTIATE_DATA_INGESTION_TEST(name)

Definition at line 863 of file CtasIntegrationTest.cpp.

Function Documentation

◆ ARRAY_COLUMN_TEST() [1/15]

ARRAY_COLUMN_TEST ( BOOLEAN  ,
"BOOLEAN"   
)

◆ ARRAY_COLUMN_TEST() [2/15]

ARRAY_COLUMN_TEST ( TINYINT  ,
"TINYINT"   
)

◆ ARRAY_COLUMN_TEST() [3/15]

ARRAY_COLUMN_TEST ( SMALLINT  ,
"SMALLINT"   
)

◆ ARRAY_COLUMN_TEST() [4/15]

ARRAY_COLUMN_TEST ( INTEGER  ,
"INTEGER"   
)

◆ ARRAY_COLUMN_TEST() [5/15]

ARRAY_COLUMN_TEST ( BIGINT  ,
"BIGINT"   
)

◆ ARRAY_COLUMN_TEST() [6/15]

ARRAY_COLUMN_TEST ( FLOAT  ,
"FLOAT"   
)

◆ ARRAY_COLUMN_TEST() [7/15]

ARRAY_COLUMN_TEST ( DOUBLE  ,
"DOUBLE"   
)

◆ ARRAY_COLUMN_TEST() [8/15]

ARRAY_COLUMN_TEST ( NUMERIC  ,
"NUMERIC(18)"   
)

◆ ARRAY_COLUMN_TEST() [9/15]

ARRAY_COLUMN_TEST ( DECIMAL  ,
"DECIMAL(18,9)"   
)

◆ ARRAY_COLUMN_TEST() [10/15]

ARRAY_COLUMN_TEST ( CHAR  ,
"CHAR(100)"   
)

◆ ARRAY_COLUMN_TEST() [11/15]

ARRAY_COLUMN_TEST ( VARCHAR  ,
"VARCHAR(100)"   
)

◆ ARRAY_COLUMN_TEST() [12/15]

ARRAY_COLUMN_TEST ( TEXT  ,
"TEXT"   
)

◆ ARRAY_COLUMN_TEST() [13/15]

ARRAY_COLUMN_TEST ( TIME  ,
"TIME"   
)

◆ ARRAY_COLUMN_TEST() [14/15]

ARRAY_COLUMN_TEST ( DATE  ,
"DATE"   
)

◆ ARRAY_COLUMN_TEST() [15/15]

ARRAY_COLUMN_TEST ( TIMESTAMP  ,
"TIMESTAMP"   
)

◆ BOOLEAN_COLUMN_TEST()

BOOLEAN_COLUMN_TEST ( BOOLEAN  ,
int64_t  ,
"BOOLEAN"  ,
kBOOLEAN  ,
NULL_TINYINT   
)

◆ checked_get() [1/6]

template<typename RETURN_TYPE , typename SOURCE_TYPE >
bool checked_get ( size_t  row,
const SOURCE_TYPE *  boost_variant,
RETURN_TYPE &  val,
RETURN_TYPE  null_value 
)

Definition at line 46 of file CtasIntegrationTest.cpp.

Referenced by NumberColumnDescriptor< T >::check_column_value(), BooleanColumnDescriptor::check_column_value(), StringColumnDescriptor::check_column_value(), DateTimeColumnDescriptor::check_column_value(), GeoPointColumnDescriptor::check_column_value(), GeoLinestringColumnDescriptor::check_column_value(), GeoMultiPolygonColumnDescriptor::check_column_value(), and GeoPolygonColumnDescriptor::check_column_value().

49  {
50  const auto val_p = boost::get<RETURN_TYPE>(boost_variant);
51  if (nullptr == val_p) {
52  return false;
53  }
54 
55  val = *val_p;
56  return true;
57 }
+ Here is the caller graph for this function:

◆ checked_get() [2/6]

template<>
bool checked_get ( size_t  row,
const ScalarTargetValue boost_variant,
std::string &  val,
std::string  null_value 
)

Definition at line 60 of file CtasIntegrationTest.cpp.

63  {
64  const auto val_p = boost::get<NullableString>(boost_variant);
65  if (nullptr == val_p) {
66  return false;
67  }
68 
69  const auto mapd_str_p = boost::get<std::string>(val_p);
70 
71  if (nullptr == mapd_str_p) {
72  val = null_value;
73  } else {
74  val = *mapd_str_p;
75  }
76 
77  return true;
78 }

◆ checked_get() [3/6]

template<>
bool checked_get ( size_t  row,
const TDatum *  datum,
int64_t &  val,
int64_t  null_value 
)

Definition at line 81 of file CtasIntegrationTest.cpp.

81  {
82  if (datum->is_null) {
83  val = null_value;
84  } else {
85  val = datum->val.int_val;
86  }
87 
88  return true;
89 }

◆ checked_get() [4/6]

template<>
bool checked_get ( size_t  row,
const TDatum *  datum,
float &  val,
float  null_value 
)

Definition at line 92 of file CtasIntegrationTest.cpp.

92  {
93  if (datum->is_null) {
94  val = null_value;
95  } else {
96  val = (float)datum->val.real_val;
97  }
98  return true;
99 }

◆ checked_get() [5/6]

template<>
bool checked_get ( size_t  row,
const TDatum *  datum,
double &  val,
double  null_value 
)

Definition at line 102 of file CtasIntegrationTest.cpp.

102  {
103  if (datum->is_null) {
104  val = null_value;
105  } else {
106  val = datum->val.real_val;
107  }
108 
109  return true;
110 }

◆ checked_get() [6/6]

template<>
bool checked_get ( size_t  row,
const TDatum *  datum,
std::string &  val,
std::string  null_value 
)

Definition at line 113 of file CtasIntegrationTest.cpp.

116  {
117  if (datum->is_null) {
118  val = null_value;
119  } else {
120  val = datum->val.str_val;
121  }
122 
123  return true;
124 }

◆ INSTANTIATE_DATA_INGESTION_TEST() [1/4]

INSTANTIATE_DATA_INGESTION_TEST ( GEO_POINT  )

◆ INSTANTIATE_DATA_INGESTION_TEST() [2/4]

INSTANTIATE_DATA_INGESTION_TEST ( GEO_LINESTRING  )

◆ INSTANTIATE_DATA_INGESTION_TEST() [3/4]

INSTANTIATE_DATA_INGESTION_TEST ( GEO_POLYGON  )

◆ INSTANTIATE_DATA_INGESTION_TEST() [4/4]

INSTANTIATE_DATA_INGESTION_TEST ( GEO_MULTI_POLYGON  )

◆ INSTANTIATE_TEST_CASE_P() [1/3]

INSTANTIATE_TEST_CASE_P ( MIXED_NO_GEO  ,
Ctas  ,
testing::Values(std::vector< std::shared_ptr< TestColumnDescriptor >>{BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, NUMERIC, DECIMAL, CHAR, VARCHAR, TEXT, TIME, DATE, TIMESTAMP})   
)

◆ INSTANTIATE_TEST_CASE_P() [2/3]

INSTANTIATE_TEST_CASE_P ( MIXED_NO_GEO  ,
Itas  ,
testing::Values(std::vector< std::shared_ptr< TestColumnDescriptor >>{BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, NUMERIC, DECIMAL, CHAR, VARCHAR, TEXT, TIME, DATE, TIMESTAMP})   
)

◆ INSTANTIATE_TEST_CASE_P() [3/3]

INSTANTIATE_TEST_CASE_P ( MIXED_WITH_GEO  ,
Update  ,
testing::Values(std::vector< std::shared_ptr< TestColumnDescriptor >>{TEXT, INTEGER, DOUBLE, GEO_POINT, GEO_LINESTRING, GEO_POLYGON, GEO_MULTI_POLYGON })   
)

◆ itasTestBody()

void itasTestBody ( std::vector< std::shared_ptr< TestColumnDescriptor >> &  columnDescriptors,
std::string  targetPartitionScheme = ")" 
)

Definition at line 716 of file CtasIntegrationTest.cpp.

References logger::ERROR, logger::INFO, LOG, num_rows, run_ddl_statement(), run_multiple_agg(), and to_string().

Referenced by TEST_P().

717  {
718  run_ddl_statement("DROP TABLE IF EXISTS ITAS_SOURCE;");
719  run_ddl_statement("DROP TABLE IF EXISTS ITAS_TARGET;");
720 
721  std::string create_source_sql = "CREATE TABLE ITAS_SOURCE (id int";
722  std::string create_target_sql = "CREATE TABLE ITAS_TARGET (id int";
723  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
724  auto tcd = columnDescriptors[col];
725  if (tcd->skip_test("CreateTableAsSelect")) {
726  LOG(ERROR) << "not supported... skipping";
727  return;
728  }
729 
730  create_source_sql +=
731  ", col_" + std::to_string(col) + " " + tcd->get_column_definition();
732  create_target_sql +=
733  ", col_" + std::to_string(col) + " " + tcd->get_column_definition();
734  }
735  create_source_sql += ");";
736  create_target_sql += targetPartitionScheme + ";";
737 
738  LOG(INFO) << create_source_sql;
739  LOG(INFO) << create_target_sql;
740 
741  run_ddl_statement(create_source_sql);
742  run_ddl_statement(create_target_sql);
743 
744  size_t num_rows = 25;
745 
746  // fill source table
747  for (unsigned int row = 0; row < num_rows; row++) {
748  std::string insert_sql = "INSERT INTO ITAS_SOURCE VALUES (" + std::to_string(row);
749  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
750  auto tcd = columnDescriptors[col];
751  insert_sql += ", " + tcd->get_column_value(row);
752  }
753  insert_sql += ");";
754 
755  // LOG(INFO) << "insert_sql: " << insert_sql;
756 
757  run_multiple_agg(insert_sql);
758  }
759 
760  // execute CTAS
761  std::string insert_itas_sql = "INSERT INTO ITAS_TARGET SELECT * FROM ITAS_SOURCE;";
762  LOG(INFO) << insert_itas_sql;
763 
764  run_ddl_statement(insert_itas_sql);
765 
766  // compare source against CTAS
767  std::string select_sql = "SELECT * FROM ITAS_SOURCE ORDER BY id;";
768  std::string select_itas_sql = "SELECT * FROM ITAS_TARGET ORDER BY id;";
769 
770  LOG(INFO) << select_sql;
771  auto select_result = run_multiple_agg(select_sql);
772 
773  LOG(INFO) << select_itas_sql;
774  auto select_itas_result = run_multiple_agg(select_itas_sql);
775 
776  ASSERT_EQ(num_rows, select_result.row_set.rows.size());
777  ASSERT_EQ(num_rows, select_itas_result.row_set.rows.size());
778 
779  for (unsigned int row = 0; row < num_rows; row++) {
780  const auto select_crt_row = select_result.row_set.rows[row];
781  const auto select_itas_crt_row = select_itas_result.row_set.rows[row];
782 
783  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
784  auto tcd = columnDescriptors[col];
785 
786  {
787  const auto mapd_variant = select_crt_row.cols[col + 1];
788  ASSERT_EQ(true, tcd->check_column_value(row, &mapd_variant));
789  }
790  {
791  const auto mapd_variant = select_itas_crt_row.cols[col + 1];
792  ASSERT_EQ(true, tcd->check_column_value(row, &mapd_variant));
793  }
794  }
795  }
796 }
const int8_t const int64_t * num_rows
#define LOG(tag)
Definition: Logger.h:182
std::string to_string(char const *&&v)
void run_ddl_statement(std::string ddl)
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 1040 of file CtasIntegrationTest.cpp.

References logger::ERROR, g_client, g_session_id, TestHelpers::init_logger_stderr_only(), LOG, run, and anonymous_namespace{DBObjectPrivilegesTest.cpp}::user.

1040  {
1041  int err = 0;
1043 
1044  try {
1045  testing::InitGoogleTest(&argc, argv);
1046 
1047  namespace po = boost::program_options;
1048 
1049  po::options_description desc("Options");
1050 
1051  // these two are here to allow passing correctly google testing parameters
1052  desc.add_options()("gtest_list_tests", "list all test");
1053  desc.add_options()("gtest_filter", "filters tests, use --help for details");
1054 
1055  std::string host = "localhost";
1056  int port = 6274;
1057  std::string cert = "";
1058 
1059  std::string user = "admin";
1060  std::string pwd = "HyperInteractive";
1061  std::string db = "omnisci";
1062 
1063  desc.add_options()(
1064  "host",
1065  po::value<std::string>(&host)->default_value(host)->implicit_value(host),
1066  "hostname of target server");
1067  desc.add_options()("port",
1068  po::value<int>(&port)->default_value(port)->implicit_value(port),
1069  "tcp port of target server");
1070  desc.add_options()(
1071  "cert",
1072  po::value<std::string>(&cert)->default_value(cert)->implicit_value(cert),
1073  "tls/ssl certificate to use for contacting target server");
1074  desc.add_options()(
1075  "user",
1076  po::value<std::string>(&user)->default_value(user)->implicit_value(user),
1077  "user name to connect as");
1078  desc.add_options()(
1079  "pwd",
1080  po::value<std::string>(&pwd)->default_value(pwd)->implicit_value(pwd),
1081  "password to connect with");
1082  desc.add_options()("db",
1083  po::value<std::string>(&db)->default_value(db)->implicit_value(db),
1084  "db to connect to");
1085 
1086  po::variables_map vm;
1087  po::store(po::command_line_parser(argc, argv).options(desc).run(), vm);
1088  po::notify(vm);
1089  mapd::shared_ptr<ThriftClientConnection> connMgr;
1090  connMgr = std::make_shared<ThriftClientConnection>();
1091  auto transport = connMgr->open_buffered_client_transport(host, port, cert);
1092  transport->open();
1093  auto protocol = std::make_shared<TBinaryProtocol>(transport);
1094  g_client = std::make_shared<MapDClient>(protocol);
1095 
1096  g_client->connect(g_session_id, user, pwd, db);
1097 
1098  err = RUN_ALL_TESTS();
1099 
1100  } catch (const std::exception& e) {
1101  LOG(ERROR) << e.what();
1102  err = -1;
1103  }
1104 
1105  return err;
1106 }
#define LOG(tag)
Definition: Logger.h:182
std::shared_ptr< MapDClient > g_client
TSessionId g_session_id
void init_logger_stderr_only(int argc, char const *const *argv)
Definition: TestHelpers.h:194
static bool run
+ Here is the call graph for this function:

◆ NUMBER_COLUMN_TEST() [1/18]

NUMBER_COLUMN_TEST ( TINYINT  ,
int64_t  ,
"TINYINT"  ,
kTINYINT  ,
NULL_TINYINT   
)

◆ NUMBER_COLUMN_TEST() [2/18]

NUMBER_COLUMN_TEST ( SMALLINT  ,
int64_t  ,
"SMALLINT"  ,
kSMALLINT  ,
NULL_SMALLINT   
)

◆ NUMBER_COLUMN_TEST() [3/18]

NUMBER_COLUMN_TEST ( SMALLINT_8  ,
int64_t  ,
"SMALLINT ENCODING FIXED(8)"  ,
kSMALLINT  ,
NULL_SMALLINT   
)

◆ NUMBER_COLUMN_TEST() [4/18]

NUMBER_COLUMN_TEST ( INTEGER  ,
int64_t  ,
"INTEGER"  ,
kINT  ,
NULL_INT   
)

◆ NUMBER_COLUMN_TEST() [5/18]

NUMBER_COLUMN_TEST ( INTEGER_8  ,
int64_t  ,
"INTEGER ENCODING FIXED(8)"  ,
kINT  ,
NULL_INT   
)

◆ NUMBER_COLUMN_TEST() [6/18]

NUMBER_COLUMN_TEST ( INTEGER_16  ,
int64_t  ,
"INTEGER ENCODING FIXED(16)"  ,
kINT  ,
NULL_INT   
)

◆ NUMBER_COLUMN_TEST() [7/18]

NUMBER_COLUMN_TEST ( BIGINT  ,
int64_t  ,
"BIGINT"  ,
kBIGINT  ,
NULL_BIGINT   
)

◆ NUMBER_COLUMN_TEST() [8/18]

NUMBER_COLUMN_TEST ( BIGINT_8  ,
int64_t  ,
"BIGINT ENCODING FIXED(8)"  ,
kBIGINT  ,
NULL_BIGINT   
)

◆ NUMBER_COLUMN_TEST() [9/18]

NUMBER_COLUMN_TEST ( BIGINT_16  ,
int64_t  ,
"BIGINT ENCODING FIXED(16)"  ,
kBIGINT  ,
NULL_BIGINT   
)

◆ NUMBER_COLUMN_TEST() [10/18]

NUMBER_COLUMN_TEST ( BIGINT_32  ,
int64_t  ,
"BIGINT ENCODING FIXED(32)"  ,
kBIGINT  ,
NULL_BIGINT   
)

◆ NUMBER_COLUMN_TEST() [11/18]

NUMBER_COLUMN_TEST ( FLOAT  ,
float  ,
"FLOAT"  ,
kFLOAT  ,
NULL_FLOAT   
)

◆ NUMBER_COLUMN_TEST() [12/18]

NUMBER_COLUMN_TEST ( DOUBLE  ,
double  ,
"DOUBLE"  ,
kDOUBLE  ,
NULL_DOUBLE   
)

◆ NUMBER_COLUMN_TEST() [13/18]

NUMBER_COLUMN_TEST ( NUMERIC  ,
double  ,
"NUMERIC(18)"  ,
kNUMERIC  ,
NULL_DOUBLE   
)

◆ NUMBER_COLUMN_TEST() [14/18]

NUMBER_COLUMN_TEST ( NUMERIC_32  ,
double  ,
"NUMERIC(9) ENCODING FIXED(32)"  ,
kNUMERIC  ,
NULL_DOUBLE   
)

◆ NUMBER_COLUMN_TEST() [15/18]

NUMBER_COLUMN_TEST ( NUMERIC_16  ,
double  ,
"NUMERIC(4) ENCODING FIXED(16)"  ,
kNUMERIC  ,
NULL_DOUBLE   
)

◆ NUMBER_COLUMN_TEST() [16/18]

NUMBER_COLUMN_TEST ( DECIMAL  ,
double  ,
"DECIMAL(18,9)"  ,
kDECIMAL  ,
NULL_DOUBLE   
)

◆ NUMBER_COLUMN_TEST() [17/18]

NUMBER_COLUMN_TEST ( DECIMAL_32  ,
double  ,
"DECIMAL(9,2) ENCODING FIXED(32)"  ,
kDECIMAL  ,
NULL_DOUBLE   
)

◆ NUMBER_COLUMN_TEST() [18/18]

NUMBER_COLUMN_TEST ( DECIMAL_16  ,
double  ,
"DECIMAL(4,2) ENCODING FIXED(16)"  ,
kDECIMAL  ,
NULL_DOUBLE   
)

◆ run_ddl_statement()

void run_ddl_statement ( std::string  ddl)

Definition at line 596 of file CtasIntegrationTest.cpp.

References run_multiple_agg().

Referenced by anonymous_namespace{AlterColumnTest.cpp}::alter_common(), BODY_F(), check_grant_access(), anonymous_namespace{ExecuteTest.cpp}::create_and_populate_rounding_table(), anonymous_namespace{TopKTest.cpp}::create_and_populate_tables(), anonymous_namespace{ExecuteTest.cpp}::create_and_populate_tables(), anonymous_namespace{ExecuteTest.cpp}::create_and_populate_window_func_table(), anonymous_namespace{ExecuteTest.cpp}::create_as_select(), anonymous_namespace{ExecuteTest.cpp}::create_as_select_empty(), anonymous_namespace{ImportTest.cpp}::create_minisort_table_on_column(), anonymous_namespace{ImportTest.cpp}::create_minisort_table_on_column_with_ctas(), anonymous_namespace{ExecuteTest.cpp}::create_sharded_join_table(), create_tables(), create_views(), anonymous_namespace{ExecuteTest.cpp}::create_views(), GrantSyntax::drop_tables(), TableObject::drop_tables(), anonymous_namespace{TopKTest.cpp}::drop_tables(), drop_tables(), anonymous_namespace{ExecuteTest.cpp}::drop_tables(), drop_views(), anonymous_namespace{ExecuteTest.cpp}::drop_views(), drop_views_and_tables(), anonymous_namespace{ExecuteTest.cpp}::import_big_decimal_range_test(), anonymous_namespace{ExecuteTest.cpp}::import_coalesce_cols_join_test(), anonymous_namespace{ExecuteTest.cpp}::import_decimal_compression_test(), anonymous_namespace{ExecuteTest.cpp}::import_dept_table(), anonymous_namespace{ExecuteTest.cpp}::import_emp_table(), anonymous_namespace{ExecuteTest.cpp}::import_empty_table_test(), anonymous_namespace{ExecuteTest.cpp}::import_geospatial_join_test(), anonymous_namespace{ExecuteTest.cpp}::import_geospatial_test(), anonymous_namespace{ExecuteTest.cpp}::import_gpu_sort_test(), anonymous_namespace{ExecuteTest.cpp}::import_hash_join_test(), anonymous_namespace{ExecuteTest.cpp}::import_join_test(), anonymous_namespace{ExecuteTest.cpp}::import_logical_size_test(), anonymous_namespace{ExecuteTest.cpp}::import_query_rewrite_test(), anonymous_namespace{ExecuteTest.cpp}::import_subquery_test(), anonymous_namespace{ImportTest.cpp}::import_test_common(), anonymous_namespace{ImportTest.cpp}::import_test_local_geo(), anonymous_namespace{ExecuteTest.cpp}::import_test_table_with_lots_of_columns(), anonymous_namespace{ExecuteTest.cpp}::import_text_group_by_test(), anonymous_namespace{AlterColumnTest.cpp}::init_table_data(), anonymous_namespace{UpdelStorageTest.cpp}::init_table_data(), itasTestBody(), ViewObject::remove_objects(), anonymous_namespace{ImportTest.cpp}::run_mixed_dates_test(), anonymous_namespace{ImportTest.cpp}::run_mixed_timestamps_test(), MultiFragMetadataUpdate::SetUp(), MetadataUpdate< NSHARDS >::SetUp(), anonymous_namespace{ImportTest.cpp}::ImportTestMiniSort::SetUp(), anonymous_namespace{ImportTest.cpp}::ImportTestMixedVarlen::SetUp(), anonymous_namespace{ImportTest.cpp}::ImportTestDate::SetUp(), anonymous_namespace{ImportTest.cpp}::ImportTestLegacyDate::SetUp(), anonymous_namespace{ImportTest.cpp}::ImportTestDateArray::SetUp(), anonymous_namespace{ImportTest.cpp}::ImportTestTimestamps::SetUp(), anonymous_namespace{ImportTest.cpp}::ImportTest::SetUp(), anonymous_namespace{ImportTest.cpp}::ImportTestSharded::SetUp(), anonymous_namespace{ImportTest.cpp}::ImportTestShardedText::SetUp(), anonymous_namespace{ImportTest.cpp}::ImportTestShardedText8::SetUp(), anonymous_namespace{ImportTest.cpp}::GeoImportTest::SetUp(), anonymous_namespace{ImportTest.cpp}::GeoGDALImportTest::SetUp(), JoinTest::SetUp(), ViewObject::setup_objects(), GrantSyntax::setup_tables(), TableObject::setup_tables(), shard_key_test_runner(), anonymous_namespace{UpdateMetadataTest.cpp}::TableCycler::TableCycler(), anonymous_namespace{AlterColumnTest.cpp}::AlterColumnTest::TearDown(), MultiFragMetadataUpdate::TearDown(), MetadataUpdate< NSHARDS >::TearDown(), anonymous_namespace{ImportTest.cpp}::ImportTestMiniSort::TearDown(), anonymous_namespace{ImportTest.cpp}::ImportTestMixedVarlen::TearDown(), anonymous_namespace{ImportTest.cpp}::ImportTestDate::TearDown(), anonymous_namespace{ImportTest.cpp}::ImportTestLegacyDate::TearDown(), anonymous_namespace{ImportTest.cpp}::ImportTestDateArray::TearDown(), anonymous_namespace{UpdelStorageTest.cpp}::RowVacuumTestWithVarlenAndArraysN< N >::TearDown(), anonymous_namespace{ImportTest.cpp}::ImportTestTimestamps::TearDown(), anonymous_namespace{UpdelStorageTest.cpp}::RowVacuumTest::TearDown(), anonymous_namespace{UpdelStorageTest.cpp}::UpdateStorageTest::TearDown(), anonymous_namespace{ImportTest.cpp}::ImportTest::TearDown(), anonymous_namespace{ImportTest.cpp}::ImportTestSharded::TearDown(), anonymous_namespace{ImportTest.cpp}::ImportTestShardedText::TearDown(), anonymous_namespace{ImportTest.cpp}::ImportTestShardedText8::TearDown(), anonymous_namespace{ImportTest.cpp}::GeoImportTest::TearDown(), anonymous_namespace{ImportTest.cpp}::GeoGDALImportTest::TearDown(), JoinTest::TearDown(), anonymous_namespace{AlterColumnTest.cpp}::TEST(), TEST(), TEST_F(), anonymous_namespace{ImportTest.cpp}::TEST_F(), anonymous_namespace{UpdelStorageTest.cpp}::TEST_F(), TEST_P(), updateColumnByLiteralTest(), anonymous_namespace{ExecuteTest.cpp}::validate_storage_options(), and anonymous_namespace{UpdateMetadataTest.cpp}::TableCycler::~TableCycler().

596  {
597  run_multiple_agg(ddl);
598 }
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

◆ run_multiple_agg()

TQueryResult run_multiple_agg ( std::string  sql)

Definition at line 590 of file CtasIntegrationTest.cpp.

References g_client, g_session_id, and run-benchmark-import::result.

Referenced by BODY_F(), anonymous_namespace{TopKTest.cpp}::SQLiteComparator::compare(), anonymous_namespace{ExecuteTest.cpp}::SQLiteComparator::compare(), anonymous_namespace{TopKTest.cpp}::SQLiteComparator::compare_timstamp_approx(), anonymous_namespace{ExecuteTest.cpp}::SQLiteComparator::compare_timstamp_approx(), anonymous_namespace{ExecuteTest.cpp}::create_and_populate_rounding_table(), anonymous_namespace{TopKTest.cpp}::create_and_populate_tables(), anonymous_namespace{ExecuteTest.cpp}::create_and_populate_tables(), anonymous_namespace{ExecuteTest.cpp}::create_and_populate_window_func_table(), anonymous_namespace{ExecuteTest.cpp}::create_sharded_join_table(), anonymous_namespace{ExecuteTest.cpp}::get_first_target(), anonymous_namespace{ExecuteTest.cpp}::import_big_decimal_range_test(), anonymous_namespace{ExecuteTest.cpp}::import_coalesce_cols_join_test(), anonymous_namespace{ExecuteTest.cpp}::import_decimal_compression_test(), anonymous_namespace{ExecuteTest.cpp}::import_dept_table(), anonymous_namespace{ExecuteTest.cpp}::import_emp_table(), anonymous_namespace{ExecuteTest.cpp}::import_geospatial_join_test(), anonymous_namespace{ExecuteTest.cpp}::import_geospatial_test(), anonymous_namespace{ExecuteTest.cpp}::import_gpu_sort_test(), anonymous_namespace{ExecuteTest.cpp}::import_hash_join_test(), anonymous_namespace{ExecuteTest.cpp}::import_join_test(), anonymous_namespace{ExecuteTest.cpp}::import_logical_size_test(), anonymous_namespace{ExecuteTest.cpp}::import_query_rewrite_test(), anonymous_namespace{ExecuteTest.cpp}::import_subquery_test(), anonymous_namespace{ExecuteTest.cpp}::import_test_table_with_lots_of_columns(), anonymous_namespace{ExecuteTest.cpp}::import_text_group_by_test(), itasTestBody(), run_ddl_statement(), anonymous_namespace{TopKTest.cpp}::run_multiple_agg(), anonymous_namespace{UdfTest.cpp}::run_multiple_agg(), anonymous_namespace{UdfTest.cpp}::run_simple_agg(), LowGpuBufferMemory::SetUp(), MultiFragMetadataUpdate::SetUp(), LowGpuBufferMemoryCpuRetry::SetUp(), MediumGpuBufferMemory::SetUp(), MetadataUpdate< NSHARDS >::SetUp(), JoinTest::SetUp(), shard_key_test_runner(), TEST(), TEST_F(), TEST_P(), and updateColumnByLiteralTest().

590  {
592  g_client->sql_execute(result, g_session_id, sql, false, "", -1, -1);
593  return result;
594 }
auto sql(const std::string &sql_stmts)
std::shared_ptr< MapDClient > g_client
TSessionId g_session_id
+ Here is the caller graph for this function:

◆ STRING_COLUMN_TEST() [1/15]

STRING_COLUMN_TEST ( CHAR  ,
"CHAR(100)"  ,
kCHAR   
)

◆ STRING_COLUMN_TEST() [2/15]

STRING_COLUMN_TEST ( CHAR_DICT  ,
"CHAR(100) ENCODING DICT"  ,
kCHAR   
)

◆ STRING_COLUMN_TEST() [3/15]

STRING_COLUMN_TEST ( CHAR_DICT_8  ,
"CHAR(100) ENCODING DICT(8)"  ,
kCHAR   
)

◆ STRING_COLUMN_TEST() [4/15]

STRING_COLUMN_TEST ( CHAR_DICT_16  ,
"CHAR(100) ENCODING DICT(16)"  ,
kCHAR   
)

◆ STRING_COLUMN_TEST() [5/15]

STRING_COLUMN_TEST ( CHAR_NONE  ,
"CHAR(100) ENCODING NONE ,
kCHAR   
)

◆ STRING_COLUMN_TEST() [6/15]

STRING_COLUMN_TEST ( VARCHAR  ,
"VARCHAR(100)"  ,
kCHAR   
)

◆ STRING_COLUMN_TEST() [7/15]

STRING_COLUMN_TEST ( VARCHAR_DICT  ,
"VARCHAR(100) ENCODING DICT"  ,
kCHAR   
)

◆ STRING_COLUMN_TEST() [8/15]

STRING_COLUMN_TEST ( VARCHAR_DICT_8  ,
"VARCHAR(100) ENCODING DICT(8)"  ,
kCHAR   
)

◆ STRING_COLUMN_TEST() [9/15]

STRING_COLUMN_TEST ( VARCHAR_DICT_16  ,
"VARCHAR(100) ENCODING DICT(16)"  ,
kCHAR   
)

◆ STRING_COLUMN_TEST() [10/15]

STRING_COLUMN_TEST ( VARCHAR_NONE  ,
"VARCHAR(100) ENCODING NONE ,
kCHAR   
)

◆ STRING_COLUMN_TEST() [11/15]

STRING_COLUMN_TEST ( TEXT  ,
"TEXT"  ,
kTEXT   
)

◆ STRING_COLUMN_TEST() [12/15]

STRING_COLUMN_TEST ( TEXT_DICT  ,
"TEXT ENCODING DICT"  ,
kTEXT   
)

◆ STRING_COLUMN_TEST() [13/15]

STRING_COLUMN_TEST ( TEXT_DICT_8  ,
"TEXT ENCODING DICT(8)"  ,
kTEXT   
)

◆ STRING_COLUMN_TEST() [14/15]

STRING_COLUMN_TEST ( TEXT_DICT_16  ,
"TEXT ENCODING DICT(16)"  ,
kTEXT   
)

◆ STRING_COLUMN_TEST() [15/15]

STRING_COLUMN_TEST ( TEXT_NONE  ,
"TEXT ENCODING NONE ,
kTEXT   
)

◆ TEST()

TEST ( Ctas  ,
SyntaxCheck   
)

Definition at line 600 of file CtasIntegrationTest.cpp.

References run_ddl_statement().

600  {
601  std::string ddl = "DROP TABLE IF EXISTS CTAS_SOURCE;";
602  run_ddl_statement(ddl);
603  ddl = "DROP TABLE IF EXISTS CTAS_TARGET;";
604 
605  run_ddl_statement(ddl);
606 
607  run_ddl_statement("CREATE TABLE CTAS_SOURCE (id int);");
608 
609  ddl = "CREATE TABLE CTAS_TARGET AS SELECT * FROM CTAS_SOURCE;";
610  run_ddl_statement(ddl);
611  EXPECT_THROW(run_ddl_statement(ddl), apache::thrift::TException);
612  ddl = "DROP TABLE CTAS_TARGET;";
613  run_ddl_statement(ddl);
614 
615  ddl = "CREATE TEMPORARY TABLE CTAS_TARGET AS SELECT * FROM CTAS_SOURCE;";
616  run_ddl_statement(ddl);
617  EXPECT_THROW(run_ddl_statement(ddl), apache::thrift::TException);
618  ddl = "DROP TABLE CTAS_TARGET;";
619  run_ddl_statement(ddl);
620 
621  ddl = "CREATE TABLE CTAS_TARGET AS SELECT * FROM CTAS_SOURCE WITH( FRAGMENT_SIZE=3 );";
622  run_ddl_statement(ddl);
623  EXPECT_THROW(run_ddl_statement(ddl), apache::thrift::TException);
624  ddl = "DROP TABLE CTAS_TARGET;";
625  run_ddl_statement(ddl);
626 
627  ddl = "CREATE TABLE CTAS_TARGET AS SELECT * FROM CTAS_SOURCE WITH( MAX_CHUNK_SIZE=3 );";
628  run_ddl_statement(ddl);
629  EXPECT_THROW(run_ddl_statement(ddl), apache::thrift::TException);
630  ddl = "DROP TABLE CTAS_TARGET;";
631  run_ddl_statement(ddl);
632 }
void run_ddl_statement(std::string ddl)
+ Here is the call graph for this function:

◆ TEST_P() [1/4]

TEST_P ( Ctas  ,
CreateTableAsSelect   
)

Definition at line 634 of file CtasIntegrationTest.cpp.

References logger::ERROR, g_client, g_session_id, logger::INFO, LOG, num_rows, run_ddl_statement(), run_multiple_agg(), and to_string().

634  {
635  run_ddl_statement("DROP TABLE IF EXISTS CTAS_SOURCE;");
636  run_ddl_statement("DROP TABLE IF EXISTS CTAS_TARGET;");
637 
638  std::string create_sql = "CREATE TABLE CTAS_SOURCE (id int";
639  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
640  auto tcd = columnDescriptors[col];
641  if (tcd->skip_test("CreateTableAsSelect")) {
642  LOG(ERROR) << "not supported... skipping";
643  return;
644  }
645 
646  create_sql += ", col_" + std::to_string(col) + " " + tcd->get_column_definition();
647  }
648  create_sql += ");";
649 
650  LOG(INFO) << create_sql;
651 
652  run_ddl_statement(create_sql);
653 
654  size_t num_rows = 25;
655 
656  // fill source table
657  for (unsigned int row = 0; row < num_rows; row++) {
658  std::string insert_sql = "INSERT INTO CTAS_SOURCE VALUES (" + std::to_string(row);
659  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
660  auto tcd = columnDescriptors[col];
661  insert_sql += ", " + tcd->get_column_value(row);
662  }
663  insert_sql += ");";
664 
665  // LOG(INFO) << "insert_sql: " << insert_sql;
666 
667  run_multiple_agg(insert_sql);
668  }
669 
670  // execute CTAS
671  std::string create_ctas_sql = "CREATE TABLE CTAS_TARGET AS SELECT * FROM CTAS_SOURCE;";
672  LOG(INFO) << create_ctas_sql;
673 
674  run_ddl_statement(create_ctas_sql);
675 
676  // check tables
677  TTableDetails td_source;
678  TTableDetails td_target;
679 
680  g_client->get_table_details(td_source, g_session_id, "CTAS_SOURCE");
681  g_client->get_table_details(td_target, g_session_id, "CTAS_TARGET");
682  ASSERT_EQ(td_source.row_desc.size(), td_target.row_desc.size());
683 
684  // compare source against CTAS
685  std::string select_sql = "SELECT * FROM CTAS_SOURCE ORDER BY id;";
686  std::string select_ctas_sql = "SELECT * FROM CTAS_TARGET ORDER BY id;";
687 
688  LOG(INFO) << select_sql;
689  auto select_result = run_multiple_agg(select_sql);
690 
691  LOG(INFO) << select_ctas_sql;
692  auto select_ctas_result = run_multiple_agg(select_ctas_sql);
693 
694  ASSERT_EQ(num_rows, select_result.row_set.rows.size());
695  ASSERT_EQ(num_rows, select_ctas_result.row_set.rows.size());
696 
697  for (unsigned int row = 0; row < num_rows; row++) {
698  const auto select_crt_row = select_result.row_set.rows[row];
699  const auto select_ctas_crt_row = select_ctas_result.row_set.rows[row];
700 
701  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
702  auto tcd = columnDescriptors[col];
703 
704  {
705  const auto mapd_variant = select_crt_row.cols[col + 1];
706  ASSERT_EQ(true, tcd->check_column_value(row, &mapd_variant));
707  }
708  {
709  const auto mapd_variant = select_ctas_crt_row.cols[col + 1];
710  ASSERT_EQ(true, tcd->check_column_value(row, &mapd_variant));
711  }
712  }
713  }
714 }
const int8_t const int64_t * num_rows
#define LOG(tag)
Definition: Logger.h:182
std::string to_string(char const *&&v)
std::shared_ptr< MapDClient > g_client
TSessionId g_session_id
void run_ddl_statement(std::string ddl)
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

◆ TEST_P() [2/4]

TEST_P ( Itas  ,
InsertIntoTableFromSelect   
)

Definition at line 798 of file CtasIntegrationTest.cpp.

References itasTestBody().

798  {
799  itasTestBody(columnDescriptors, ")");
800 }
void itasTestBody(std::vector< std::shared_ptr< TestColumnDescriptor >> &columnDescriptors, std::string targetPartitionScheme=")")
+ Here is the call graph for this function:

◆ TEST_P() [3/4]

TEST_P ( Itas  ,
InsertIntoTableFromSelectReplicated   
)

Definition at line 802 of file CtasIntegrationTest.cpp.

References itasTestBody().

802  {
803  itasTestBody(columnDescriptors, ") WITH (partitions='REPLICATED')");
804 }
void itasTestBody(std::vector< std::shared_ptr< TestColumnDescriptor >> &columnDescriptors, std::string targetPartitionScheme=")")
+ Here is the call graph for this function:

◆ TEST_P() [4/4]

TEST_P ( Itas  ,
InsertIntoTableFromSelectSharded   
)

Definition at line 806 of file CtasIntegrationTest.cpp.

References itasTestBody().

806  {
807  itasTestBody(columnDescriptors,
808  ", SHARD KEY (id)) WITH (shard_count = 4, partitions='SHARDED')");
809 }
void itasTestBody(std::vector< std::shared_ptr< TestColumnDescriptor >> &columnDescriptors, std::string targetPartitionScheme=")")
+ Here is the call graph for this function:

◆ TIME_COLUMN_TEST() [1/6]

TIME_COLUMN_TEST ( TIME  ,
"TIME"  ,
kTIME  ,
"%T"  ,
,
 
)

◆ TIME_COLUMN_TEST() [2/6]

TIME_COLUMN_TEST ( TIME_32  ,
"TIME ENCODING FIXED(32)"  ,
kTIME  ,
"%T"  ,
,
 
)

◆ TIME_COLUMN_TEST() [3/6]

TIME_COLUMN_TEST ( DATE  ,
"DATE"  ,
kDATE  ,
"%F"  ,
,
160 *60 *  100 
)

◆ TIME_COLUMN_TEST() [4/6]

TIME_COLUMN_TEST ( DATE_16  ,
"DATE ENCODING FIXED(16)"  ,
kDATE  ,
"%F"  ,
,
160 *60 *  100 
)

◆ TIME_COLUMN_TEST() [5/6]

TIME_COLUMN_TEST ( TIMESTAMP  ,
"TIMESTAMP"  ,
kTIMESTAMP  ,
"%F %T"  ,
,
160 *60 *  100 
)

◆ TIME_COLUMN_TEST() [6/6]

TIME_COLUMN_TEST ( TIMESTAMP_32  ,
"TIMESTAMP ENCODING FIXED(32)"  ,
kTIMESTAMP  ,
"%F %T"  ,
,
160 *60 *  100 
)

Variable Documentation

◆ g_client

std::shared_ptr<MapDClient> g_client

Definition at line 43 of file CtasIntegrationTest.cpp.

Referenced by main(), run_multiple_agg(), and TEST_P().

◆ g_session_id

TSessionId g_session_id

Definition at line 42 of file CtasIntegrationTest.cpp.

Referenced by main(), run_multiple_agg(), and TEST_P().

◆ GEO_LINESTRING

const std::shared_ptr<TestColumnDescriptor> GEO_LINESTRING
Initial value:

Definition at line 976 of file CtasIntegrationTest.cpp.

◆ GEO_MULTI_POLYGON

const std::shared_ptr<TestColumnDescriptor> GEO_MULTI_POLYGON
Initial value:

Definition at line 984 of file CtasIntegrationTest.cpp.

◆ GEO_POINT

const std::shared_ptr<TestColumnDescriptor> GEO_POINT
Initial value:
=
std::shared_ptr<TestColumnDescriptor>(new GeoPointColumnDescriptor(kPOINT))

Definition at line 972 of file CtasIntegrationTest.cpp.

◆ GEO_POLYGON

const std::shared_ptr<TestColumnDescriptor> GEO_POLYGON
Initial value:
=
std::shared_ptr<TestColumnDescriptor>(new GeoPolygonColumnDescriptor(kPOLYGON))

Definition at line 980 of file CtasIntegrationTest.cpp.

◆ STRING_NONE_BASE

const std::shared_ptr<TestColumnDescriptor> STRING_NONE_BASE
Initial value:
=
std::make_shared<StringColumnDescriptor>("TEXT ENCODING NONE",
"STRING_NONE_BASE")
Definition: sqltypes.h:54

Definition at line 811 of file CtasIntegrationTest.cpp.