OmniSciDB  5ade3759e0
CtasUpdateTest.cpp File Reference
#include "../QueryRunner/QueryRunner.h"
#include <gtest/gtest.h>
#include <ctime>
#include <iostream>
#include "../Parser/parser.h"
#include "../QueryEngine/ArrowResultSet.h"
#include "../QueryEngine/Execute.h"
#include "../Shared/file_delete.h"
#include "TestHelpers.h"
#include "../Shared/ConfigResolve.h"
+ Include dependency graph for CtasUpdateTest.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
 

Namespaces

 anonymous_namespace{CtasUpdateTest.cpp}
 

Macros

#define BASE_PATH   "./tmp"
 
#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)
 

Typedefs

using QR = QueryRunner::QueryRunner
 

Functions

void anonymous_namespace{CtasUpdateTest.cpp}::run_ddl_statement (const std::string &stmt)
 
std::shared_ptr< ResultSetanonymous_namespace{CtasUpdateTest.cpp}::run_multiple_agg (const std::string &sql, const ExecutorDeviceType dt)
 
 TEST (Ctas, SyntaxCheck)
 
 TEST (Ctas, LiteralStringTest)
 
 TEST_P (Ctas, CreateTableAsSelect)
 
 TEST (Itas, SyntaxCheck)
 
 TEST (Itas, DifferentColumnNames)
 
void itasTestBody (std::vector< std::shared_ptr< TestColumnDescriptor >> &columnDescriptors, std::string targetPartitionScheme=")")
 
 TEST_P (Itas, InsertIntoTableFromSelect)
 
 TEST_P (Itas, InsertIntoTableFromSelectReplicated)
 
 TEST_P (Itas, InsertIntoTableFromSelectSharded)
 
 TEST_P (Update, UpdateColumnByColumn)
 
void updateColumnByLiteralTest (std::vector< std::shared_ptr< TestColumnDescriptor >> &columnDescriptors, size_t numColsToUpdate)
 
 TEST_P (Update, UpdateColumnByLiteral)
 
 TEST_P (Update, UpdateFirstColumnByLiteral)
 
 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, int64_t, "NUMERIC(18)", kNUMERIC, NULL_BIGINT)
 
 NUMBER_COLUMN_TEST (NUMERIC_32, int64_t, "NUMERIC(9) ENCODING FIXED(32)", kNUMERIC, NULL_BIGINT)
 
 NUMBER_COLUMN_TEST (NUMERIC_16, int64_t, "NUMERIC(4) ENCODING FIXED(16)", kNUMERIC, NULL_BIGINT)
 
 ARRAY_COLUMN_TEST (NUMERIC, "NUMERIC(18)")
 
 NUMBER_COLUMN_TEST (DECIMAL, int64_t, "DECIMAL(18,9)", kDECIMAL, NULL_BIGINT)
 
 NUMBER_COLUMN_TEST (DECIMAL_32, int64_t, "DECIMAL(9,2) ENCODING FIXED(32)", kDECIMAL, NULL_BIGINT)
 
 NUMBER_COLUMN_TEST (DECIMAL_16, int64_t, "DECIMAL(4,2) ENCODING FIXED(16)", kDECIMAL, NULL_BIGINT)
 
 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_ALL, Ctas, testing::Values(ALL))
 
 INSTANTIATE_TEST_CASE_P (MIXED_ALL, Itas, testing::Values(ALL))
 
 INSTANTIATE_TEST_CASE_P (MIXED_ALL, Update, testing::Values(ALL))
 
 INSTANTIATE_TEST_CASE_P (MIXED_VARLEN_WITHOUT_GEO, Update, testing::Values(std::vector< std::shared_ptr< TestColumnDescriptor >>{ STRING_NONE_BASE, BOOLEAN_ARRAY, BOOLEAN_FIXED_LEN_ARRAY, TINYINT_ARRAY, TINYINT_FIXED_LEN_ARRAY, SMALLINT_ARRAY, SMALLINT_FIXED_LEN_ARRAY, INTEGER_ARRAY, INTEGER_FIXED_LEN_ARRAY, BIGINT_ARRAY, BIGINT_FIXED_LEN_ARRAY, NUMERIC_ARRAY, NUMERIC_FIXED_LEN_ARRAY, TEXT_NONE, TEXT_ARRAY, TEXT_FIXED_LEN_ARRAY, TIME_ARRAY, TIME_FIXED_LEN_ARRAY, DATE_ARRAY, DATE_FIXED_LEN_ARRAY, TIMESTAMP_ARRAY, TIMESTAMP_FIXED_LEN_ARRAY }))
 
int main (int argc, char *argv[])
 

Variables

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
 
const std::vector< std::shared_ptr< TestColumnDescriptor > > ALL
 

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 1302 of file CtasUpdateTest.cpp.

◆ BASE_PATH

#define BASE_PATH   "./tmp"

Definition at line 35 of file CtasUpdateTest.cpp.

Referenced by main().

◆ 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 1281 of file CtasUpdateTest.cpp.

◆ INSTANTIATE_DATA_INGESTION_TEST

#define INSTANTIATE_DATA_INGESTION_TEST (   CDT)

Definition at line 1277 of file CtasUpdateTest.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 1286 of file CtasUpdateTest.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 1291 of file CtasUpdateTest.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 1296 of file CtasUpdateTest.cpp.

Typedef Documentation

◆ QR

Definition at line 38 of file CtasUpdateTest.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   
)

◆ 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/4]

INSTANTIATE_TEST_CASE_P ( MIXED_ALL  ,
Ctas  ,
testing::Values(ALL  
)

◆ INSTANTIATE_TEST_CASE_P() [2/4]

INSTANTIATE_TEST_CASE_P ( MIXED_ALL  ,
Itas  ,
testing::Values(ALL  
)

◆ INSTANTIATE_TEST_CASE_P() [3/4]

INSTANTIATE_TEST_CASE_P ( MIXED_ALL  ,
Update  ,
testing::Values(ALL  
)

◆ INSTANTIATE_TEST_CASE_P() [4/4]

INSTANTIATE_TEST_CASE_P ( MIXED_VARLEN_WITHOUT_GEO  ,
Update  ,
testing::Values(std::vector< std::shared_ptr< TestColumnDescriptor >>{ STRING_NONE_BASE, BOOLEAN_ARRAY, BOOLEAN_FIXED_LEN_ARRAY, TINYINT_ARRAY, TINYINT_FIXED_LEN_ARRAY, SMALLINT_ARRAY, SMALLINT_FIXED_LEN_ARRAY, INTEGER_ARRAY, INTEGER_FIXED_LEN_ARRAY, BIGINT_ARRAY, BIGINT_FIXED_LEN_ARRAY, NUMERIC_ARRAY, NUMERIC_FIXED_LEN_ARRAY, TEXT_NONE, TEXT_ARRAY, TEXT_FIXED_LEN_ARRAY, TIME_ARRAY, TIME_FIXED_LEN_ARRAY, DATE_ARRAY, DATE_FIXED_LEN_ARRAY, TIMESTAMP_ARRAY, TIMESTAMP_FIXED_LEN_ARRAY })   
)

◆ itasTestBody()

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

Definition at line 963 of file CtasUpdateTest.cpp.

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

Referenced by TEST_P().

964  {
965  run_ddl_statement("DROP TABLE IF EXISTS ITAS_SOURCE;");
966  run_ddl_statement("DROP TABLE IF EXISTS ITAS_TARGET;");
967 
968  std::string create_source_sql = "CREATE TABLE ITAS_SOURCE (id int";
969  std::string create_target_sql = "CREATE TABLE ITAS_TARGET (id int";
970  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
971  auto tcd = columnDescriptors[col];
972  if (tcd->skip_test("CreateTableAsSelect")) {
973  LOG(ERROR) << "not supported... skipping";
974  return;
975  }
976 
977  create_source_sql +=
978  ", col_" + std::to_string(col) + " " + tcd->get_column_definition();
979  create_target_sql +=
980  ", col_" + std::to_string(col) + " " + tcd->get_column_definition();
981  }
982  create_source_sql += ");";
983  create_target_sql += targetPartitionScheme + ";";
984 
985  LOG(INFO) << create_source_sql;
986  LOG(INFO) << create_target_sql;
987 
988  run_ddl_statement(create_source_sql);
989  run_ddl_statement(create_target_sql);
990 
991  size_t num_rows = 25;
992 
993  // fill source table
994  for (unsigned int row = 0; row < num_rows; row++) {
995  std::string insert_sql = "INSERT INTO ITAS_SOURCE VALUES (" + std::to_string(row);
996  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
997  auto tcd = columnDescriptors[col];
998  insert_sql += ", " + tcd->get_column_value(row);
999  }
1000  insert_sql += ");";
1001 
1003  }
1004 
1005  // execute CTAS
1006  std::string insert_itas_sql = "INSERT INTO ITAS_TARGET SELECT * FROM ITAS_SOURCE;";
1007  LOG(INFO) << insert_itas_sql;
1008 
1009  run_ddl_statement(insert_itas_sql);
1010 
1011  // compare source against CTAS
1012  std::string select_sql = "SELECT * FROM ITAS_SOURCE ORDER BY id;";
1013  std::string select_itas_sql = "SELECT * FROM ITAS_TARGET ORDER BY id;";
1014 
1015  LOG(INFO) << select_sql;
1016  auto select_result = run_multiple_agg(select_sql, ExecutorDeviceType::CPU);
1017 
1018  LOG(INFO) << select_itas_sql;
1019  auto select_itas_result = run_multiple_agg(select_itas_sql, ExecutorDeviceType::CPU);
1020 
1021  ASSERT_EQ(num_rows, select_result->rowCount());
1022  ASSERT_EQ(num_rows, select_itas_result->rowCount());
1023 
1024  for (unsigned int row = 0; row < num_rows; row++) {
1025  const auto select_crt_row = select_result->getNextRow(true, false);
1026  const auto select_itas_crt_row = select_itas_result->getNextRow(true, false);
1027 
1028  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
1029  auto tcd = columnDescriptors[col];
1030 
1031  {
1032  const auto mapd_variant = select_crt_row[col + 1];
1033  auto mapd_ti = select_result->getColType(col + 1);
1034  ASSERT_EQ(true, tcd->check_column_value(row, mapd_ti, &mapd_variant));
1035  }
1036  {
1037  const auto mapd_variant = select_itas_crt_row[col + 1];
1038  auto mapd_ti = select_itas_result->getColType(col + 1);
1039  ASSERT_EQ(true, tcd->check_column_value(row, mapd_ti, &mapd_variant));
1040  }
1041  }
1042  }
1043 }
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 1517 of file CtasUpdateTest.cpp.

References BASE_PATH, logger::ERROR, QueryRunner::QueryRunner::init(), TestHelpers::init_logger_stderr_only(), LOG, and QueryRunner::QueryRunner::reset().

1517  {
1518  testing::InitGoogleTest(&argc, argv);
1520 
1522 
1523  int err{0};
1524  try {
1525  err = RUN_ALL_TESTS();
1526  } catch (const std::exception& e) {
1527  LOG(ERROR) << e.what();
1528  }
1529  QR::reset();
1530  return err;
1531 }
#define LOG(tag)
Definition: Logger.h:182
#define BASE_PATH
static QueryRunner * init(const char *db_path, const std::string &udf_filename="", const size_t max_gpu_mem=0, const int reserved_gpu_mem=256<< 20)
Definition: QueryRunner.h:70
void init_logger_stderr_only(int argc, char const *const *argv)
Definition: TestHelpers.h:194
+ 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  ,
int64_t  ,
"NUMERIC(18)"  ,
kNUMERIC  ,
NULL_BIGINT   
)

◆ NUMBER_COLUMN_TEST() [14/18]

NUMBER_COLUMN_TEST ( NUMERIC_32  ,
int64_t  ,
"NUMERIC(9) ENCODING FIXED(32)"  ,
kNUMERIC  ,
NULL_BIGINT   
)

◆ NUMBER_COLUMN_TEST() [15/18]

NUMBER_COLUMN_TEST ( NUMERIC_16  ,
int64_t  ,
"NUMERIC(4) ENCODING FIXED(16)"  ,
kNUMERIC  ,
NULL_BIGINT   
)

◆ NUMBER_COLUMN_TEST() [16/18]

NUMBER_COLUMN_TEST ( DECIMAL  ,
int64_t  ,
"DECIMAL(18,9)"  ,
kDECIMAL  ,
NULL_BIGINT   
)

◆ NUMBER_COLUMN_TEST() [17/18]

NUMBER_COLUMN_TEST ( DECIMAL_32  ,
int64_t  ,
"DECIMAL(9,2) ENCODING FIXED(32)"  ,
kDECIMAL  ,
NULL_BIGINT   
)

◆ NUMBER_COLUMN_TEST() [18/18]

NUMBER_COLUMN_TEST ( DECIMAL_16  ,
int64_t  ,
"DECIMAL(4,2) ENCODING FIXED(16)"  ,
kDECIMAL  ,
NULL_BIGINT   
)

◆ 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() [1/4]

TEST ( Ctas  ,
SyntaxCheck   
)

Definition at line 643 of file CtasUpdateTest.cpp.

References run_ddl_statement().

643  {
644  std::string ddl = "DROP TABLE IF EXISTS CTAS_SOURCE;";
645  run_ddl_statement(ddl);
646  ddl = "DROP TABLE IF EXISTS CTAS_TARGET;";
647  run_ddl_statement(ddl);
648 
649  run_ddl_statement("CREATE TABLE CTAS_SOURCE (id int);");
650 
651  ddl = "CREATE TABLE CTAS_TARGET AS SELECT * FROM CTAS_SOURCE;";
652  run_ddl_statement(ddl);
653  EXPECT_THROW(run_ddl_statement(ddl), std::runtime_error);
654  ddl = "DROP TABLE CTAS_TARGET;";
655  run_ddl_statement(ddl);
656 
657  ddl = "CREATE TEMPORARY TABLE CTAS_TARGET AS SELECT * FROM CTAS_SOURCE;";
658  run_ddl_statement(ddl);
659  EXPECT_THROW(run_ddl_statement(ddl), std::runtime_error);
660  ddl = "DROP TABLE CTAS_TARGET;";
661  run_ddl_statement(ddl);
662 
663  ddl = "CREATE TABLE CTAS_TARGET AS SELECT * FROM CTAS_SOURCE WITH( FRAGMENT_SIZE=3 );";
664  run_ddl_statement(ddl);
665  EXPECT_THROW(run_ddl_statement(ddl), std::runtime_error);
666  ddl = "DROP TABLE CTAS_TARGET;";
667  run_ddl_statement(ddl);
668 
669  ddl = "CREATE TABLE CTAS_TARGET AS SELECT * FROM CTAS_SOURCE WITH( MAX_CHUNK_SIZE=3 );";
670  run_ddl_statement(ddl);
671  EXPECT_THROW(run_ddl_statement(ddl), std::runtime_error);
672  ddl = "DROP TABLE CTAS_TARGET;";
673  run_ddl_statement(ddl);
674 }
void run_ddl_statement(std::string ddl)
+ Here is the call graph for this function:

◆ TEST() [2/4]

TEST ( Ctas  ,
LiteralStringTest   
)

Definition at line 676 of file CtasUpdateTest.cpp.

References CPU, run_ddl_statement(), run_multiple_agg(), and to_string().

676  {
677  std::string ddl = "DROP TABLE IF EXISTS CTAS_SOURCE;";
678  run_ddl_statement(ddl);
679  ddl = "DROP TABLE IF EXISTS CTAS_TARGET;";
680  run_ddl_statement(ddl);
681 
682  run_ddl_statement("CREATE TABLE CTAS_SOURCE (id int, val int);");
683 
684  run_multiple_agg("INSERT INTO CTAS_SOURCE VALUES(1,1); ", ExecutorDeviceType::CPU);
685  run_multiple_agg("INSERT INTO CTAS_SOURCE VALUES(2,2); ", ExecutorDeviceType::CPU);
686  run_multiple_agg("INSERT INTO CTAS_SOURCE VALUES(3,3); ", ExecutorDeviceType::CPU);
687 
688  ddl =
689  "CREATE TABLE CTAS_TARGET AS select id, val, (case when val=1 then 'aa' else 'bb' "
690  "end) as txt FROM CTAS_SOURCE;";
691  run_ddl_statement(ddl);
692 
693  auto check = [](int id, std::string txt) {
694  auto select_result = run_multiple_agg(
695  "SELECT txt FROM CTAS_TARGET WHERE id=" + std::to_string(id) + ";",
697 
698  const auto select_crt_row = select_result->getNextRow(true, false);
699  const auto mapd_variant = select_crt_row[0];
700  const auto scalar_mapd_variant = boost::get<ScalarTargetValue>(&mapd_variant);
701  const auto mapd_as_str_p = boost::get<NullableString>(scalar_mapd_variant);
702  const auto mapd_str_p = boost::get<std::string>(mapd_as_str_p);
703  const auto mapd_val = *mapd_str_p;
704  ASSERT_EQ(txt, mapd_val);
705  };
706 
707  check(1, "aa");
708  check(2, "bb");
709  check(3, "bb");
710 }
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:

◆ TEST() [3/4]

TEST ( Itas  ,
SyntaxCheck   
)

Definition at line 817 of file CtasUpdateTest.cpp.

References run_ddl_statement().

817  {
818  std::string ddl = "DROP TABLE IF EXISTS ITAS_SOURCE;";
819  run_ddl_statement(ddl);
820  ddl = "DROP TABLE IF EXISTS ITAS_TARGET;";
821  run_ddl_statement(ddl);
822 
823  run_ddl_statement("CREATE TABLE ITAS_SOURCE (id int, val int);");
824  run_ddl_statement("CREATE TABLE ITAS_TARGET (id int);");
825 
826  ddl = "INSERT INTO ITAS_TARGET SELECT * FROM ITAS_SOURCE;";
827  EXPECT_THROW(run_ddl_statement(ddl), std::runtime_error);
828 
829  ddl = "DROP TABLE IF EXISTS ITAS_SOURCE;";
830  run_ddl_statement(ddl);
831  ddl = "DROP TABLE IF EXISTS ITAS_TARGET;";
832  run_ddl_statement(ddl);
833 
834  run_ddl_statement("CREATE TABLE ITAS_SOURCE (id int);");
835  run_ddl_statement("CREATE TABLE ITAS_TARGET (id int, val int);");
836 
837  ddl = "INSERT INTO ITAS_TARGET SELECT * FROM ITAS_SOURCE;";
838  EXPECT_THROW(run_ddl_statement(ddl), std::runtime_error);
839 
840  ddl = "DROP TABLE IF EXISTS ITAS_SOURCE;";
841  run_ddl_statement(ddl);
842  ddl = "DROP TABLE IF EXISTS ITAS_TARGET;";
843  run_ddl_statement(ddl);
844 
845  run_ddl_statement("CREATE TABLE ITAS_SOURCE (id int);");
846  run_ddl_statement("CREATE TABLE ITAS_TARGET (id int encoding FIXED(8));");
847 
848  ddl = "INSERT INTO ITAS_TARGET SELECT * FROM ITAS_SOURCE;";
849  EXPECT_THROW(run_ddl_statement(ddl), std::runtime_error);
850 
851  ddl = "DROP TABLE IF EXISTS ITAS_SOURCE;";
852  run_ddl_statement(ddl);
853  ddl = "DROP TABLE IF EXISTS ITAS_TARGET;";
854  run_ddl_statement(ddl);
855 
856  run_ddl_statement("CREATE TABLE ITAS_SOURCE (id int encoding FIXED(8));");
857  run_ddl_statement("CREATE TABLE ITAS_TARGET (id int);");
858 
859  ddl = "INSERT INTO ITAS_TARGET SELECT * FROM ITAS_SOURCE;";
860  EXPECT_NO_THROW(run_ddl_statement(ddl));
861 
862  ddl = "DROP TABLE IF EXISTS ITAS_SOURCE;";
863  run_ddl_statement(ddl);
864  ddl = "DROP TABLE IF EXISTS ITAS_TARGET;";
865  run_ddl_statement(ddl);
866 
867  run_ddl_statement("CREATE TABLE ITAS_SOURCE (id int, val timestamp(0));");
868  run_ddl_statement("CREATE TABLE ITAS_TARGET (id int, val timestamp(3));");
869 
870  ddl = "INSERT INTO ITAS_TARGET SELECT * FROM ITAS_SOURCE;";
871  EXPECT_THROW(run_ddl_statement(ddl), std::runtime_error);
872 
873  ddl = "DROP TABLE IF EXISTS ITAS_SOURCE;";
874  run_ddl_statement(ddl);
875  ddl = "DROP TABLE IF EXISTS ITAS_TARGET;";
876  run_ddl_statement(ddl);
877 
878  run_ddl_statement("CREATE TABLE ITAS_SOURCE (id int, val text encoding none);");
879  run_ddl_statement("CREATE TABLE ITAS_TARGET (id int, val text);");
880 
881  ddl = "INSERT INTO ITAS_TARGET SELECT * FROM ITAS_SOURCE;";
882  EXPECT_THROW(run_ddl_statement(ddl), std::runtime_error);
883 
884  ddl = "DROP TABLE IF EXISTS ITAS_SOURCE;";
885  run_ddl_statement(ddl);
886  ddl = "DROP TABLE IF EXISTS ITAS_TARGET;";
887  run_ddl_statement(ddl);
888 
889  run_ddl_statement("CREATE TABLE ITAS_SOURCE (id int, val decimal(10,2));");
890  run_ddl_statement("CREATE TABLE ITAS_TARGET (id int, val decimal(10,3));");
891 
892  ddl = "INSERT INTO ITAS_TARGET SELECT * FROM ITAS_SOURCE;";
893  EXPECT_THROW(run_ddl_statement(ddl), std::runtime_error);
894 }
void run_ddl_statement(std::string ddl)
+ Here is the call graph for this function:

◆ TEST() [4/4]

TEST ( Itas  ,
DifferentColumnNames   
)

Definition at line 896 of file CtasUpdateTest.cpp.

References CPU, run_ddl_statement(), run_multiple_agg(), and to_string().

896  {
897  run_ddl_statement("DROP TABLE IF EXISTS ITAS_SOURCE;");
898 
899  run_ddl_statement("CREATE TABLE ITAS_SOURCE (id int, val int);");
900 
901  run_multiple_agg("INSERT INTO ITAS_SOURCE VALUES(1,10); ", ExecutorDeviceType::CPU);
902  run_multiple_agg("INSERT INTO ITAS_SOURCE VALUES(2,20); ", ExecutorDeviceType::CPU);
903  run_multiple_agg("INSERT INTO ITAS_SOURCE VALUES(3,30); ", ExecutorDeviceType::CPU);
904 
905  auto check = [](int id, int64_t val) {
906  auto select_result = run_multiple_agg(
907  "SELECT target_val FROM ITAS_TARGET WHERE target_id=" + std::to_string(id) + ";",
909 
910  const auto select_crt_row = select_result->getNextRow(true, false);
911  const auto mapd_variant = select_crt_row[0];
912  const auto scalar_mapd_variant = boost::get<ScalarTargetValue>(&mapd_variant);
913  const auto mapd_int_p = boost::get<int64_t>(scalar_mapd_variant);
914  const auto mapd_val = *mapd_int_p;
915  ASSERT_EQ(val, mapd_val);
916  };
917 
918  run_ddl_statement("DROP TABLE IF EXISTS ITAS_TARGET;");
919  run_ddl_statement("CREATE TABLE ITAS_TARGET (target_id int, target_val int);");
920  run_ddl_statement("INSERT INTO ITAS_TARGET SELECT id, val FROM ITAS_SOURCE;");
921 
922  check(1, 10);
923  check(2, 20);
924  check(3, 30);
925 
926  run_ddl_statement("DROP TABLE IF EXISTS ITAS_TARGET;");
927  run_ddl_statement("CREATE TABLE ITAS_TARGET (target_id int, target_val int);");
929  "INSERT INTO ITAS_TARGET (target_id, target_val) SELECT id, val FROM ITAS_SOURCE;");
930 
931  check(1, 10);
932  check(2, 20);
933  check(3, 30);
934 
935  run_ddl_statement("DROP TABLE IF EXISTS ITAS_TARGET;");
936  run_ddl_statement("CREATE TABLE ITAS_TARGET (target_id int, target_val int);");
938  "INSERT INTO ITAS_TARGET (target_val, target_id) SELECT val, id FROM ITAS_SOURCE;");
939 
940  check(1, 10);
941  check(2, 20);
942  check(3, 30);
943 
944  run_ddl_statement("DROP TABLE IF EXISTS ITAS_TARGET;");
945  run_ddl_statement("CREATE TABLE ITAS_TARGET (target_id int, target_val int);");
947  "INSERT INTO ITAS_TARGET (target_id, target_val) SELECT val, id FROM ITAS_SOURCE;");
948 
949  check(10, 1);
950  check(20, 2);
951  check(30, 3);
952 
953  run_ddl_statement("DROP TABLE IF EXISTS ITAS_TARGET;");
954  run_ddl_statement("CREATE TABLE ITAS_TARGET (target_id int, target_val int);");
956  "INSERT INTO ITAS_TARGET (target_val, target_id) SELECT id, val FROM ITAS_SOURCE;");
957 
958  check(10, 1);
959  check(20, 2);
960  check(30, 3);
961 }
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:

◆ TEST_P() [1/7]

TEST_P ( Ctas  ,
CreateTableAsSelect   
)

Definition at line 712 of file CtasUpdateTest.cpp.

References CPU, logger::ERROR, QueryRunner::QueryRunner::get(), QueryRunner::QueryRunner::getCatalog(), logger::INFO, LOG, num_rows, run_ddl_statement(), run_multiple_agg(), TableDescriptor::tableId, and to_string().

712  {
713  run_ddl_statement("DROP TABLE IF EXISTS CTAS_SOURCE;");
714  run_ddl_statement("DROP TABLE IF EXISTS CTAS_TARGET;");
715 
716  std::string create_sql = "CREATE TABLE CTAS_SOURCE (id int";
717  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
718  auto tcd = columnDescriptors[col];
719  if (tcd->skip_test("CreateTableAsSelect")) {
720  LOG(ERROR) << "not supported... skipping";
721  return;
722  }
723 
724  create_sql += ", col_" + std::to_string(col) + " " + tcd->get_column_definition();
725  }
726  create_sql += ");";
727 
728  LOG(INFO) << create_sql;
729 
730  run_ddl_statement(create_sql);
731 
732  size_t num_rows = 25;
733 
734  // fill source table
735  for (unsigned int row = 0; row < num_rows; row++) {
736  std::string insert_sql = "INSERT INTO CTAS_SOURCE VALUES (" + std::to_string(row);
737  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
738  auto tcd = columnDescriptors[col];
739  insert_sql += ", " + tcd->get_column_value(row);
740  }
741  insert_sql += ");";
742 
744  }
745 
746  // execute CTAS
747  std::string create_ctas_sql = "CREATE TABLE CTAS_TARGET AS SELECT * FROM CTAS_SOURCE;";
748  LOG(INFO) << create_ctas_sql;
749 
750  run_ddl_statement(create_ctas_sql);
751 
752  // check tables
753  auto cat = QR::get()->getCatalog();
754  const TableDescriptor* td_source = cat->getMetadataForTable("CTAS_SOURCE");
755  const TableDescriptor* td_target = cat->getMetadataForTable("CTAS_TARGET");
756 
757  auto source_cols =
758  cat->getAllColumnMetadataForTable(td_source->tableId, false, true, false);
759  auto target_cols =
760  cat->getAllColumnMetadataForTable(td_target->tableId, false, true, false);
761 
762  ASSERT_EQ(source_cols.size(), target_cols.size());
763 
764  while (source_cols.size()) {
765  auto source_col = source_cols.back();
766  auto target_col = target_cols.back();
767 
768  LOG(INFO) << "Checking: " << source_col->columnName << " vs. "
769  << target_col->columnName << " ( " << source_col->columnType.get_type_name()
770  << " vs. " << target_col->columnType.get_type_name() << " )";
771 
772  // ASSERT_EQ(source_col->columnType.get_type(), target_col->columnType.get_type());
773  // ASSERT_EQ(source_col->columnType.get_elem_type(),
774  // target_col->columnType.get_elem_type());
775  ASSERT_EQ(source_col->columnType.get_compression(),
776  target_col->columnType.get_compression());
777  ASSERT_EQ(source_col->columnType.get_size(), target_col->columnType.get_size());
778 
779  source_cols.pop_back();
780  target_cols.pop_back();
781  }
782 
783  // compare source against CTAS
784  std::string select_sql = "SELECT * FROM CTAS_SOURCE ORDER BY id;";
785  std::string select_ctas_sql = "SELECT * FROM CTAS_TARGET ORDER BY id;";
786 
787  LOG(INFO) << select_sql;
788  auto select_result = run_multiple_agg(select_sql, ExecutorDeviceType::CPU);
789 
790  LOG(INFO) << select_ctas_sql;
791  auto select_ctas_result = run_multiple_agg(select_ctas_sql, ExecutorDeviceType::CPU);
792 
793  ASSERT_EQ(num_rows, select_result->rowCount());
794  ASSERT_EQ(num_rows, select_ctas_result->rowCount());
795 
796  for (unsigned int row = 0; row < num_rows; row++) {
797  const auto select_crt_row = select_result->getNextRow(true, false);
798  const auto select_ctas_crt_row = select_ctas_result->getNextRow(true, false);
799 
800  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
801  auto tcd = columnDescriptors[col];
802 
803  {
804  const auto mapd_variant = select_crt_row[col + 1];
805  auto mapd_ti = select_result->getColType(col + 1);
806  ASSERT_EQ(true, tcd->check_column_value(row, mapd_ti, &mapd_variant));
807  }
808  {
809  const auto mapd_variant = select_ctas_crt_row[col + 1];
810  auto mapd_ti = select_ctas_result->getColType(col + 1);
811  ASSERT_EQ(true, tcd->check_column_value(row, mapd_ti, &mapd_variant));
812  }
813  }
814  }
815 }
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< Catalog_Namespace::Catalog > getCatalog() const
static QueryRunner * get()
Definition: QueryRunner.h:115
specifies the content in-memory of a row in the table metadata table
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/7]

TEST_P ( Itas  ,
InsertIntoTableFromSelect   
)

Definition at line 1045 of file CtasUpdateTest.cpp.

References itasTestBody().

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

◆ TEST_P() [3/7]

TEST_P ( Itas  ,
InsertIntoTableFromSelectReplicated   
)

Definition at line 1049 of file CtasUpdateTest.cpp.

References itasTestBody().

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

◆ TEST_P() [4/7]

TEST_P ( Itas  ,
InsertIntoTableFromSelectSharded   
)

Definition at line 1053 of file CtasUpdateTest.cpp.

References itasTestBody().

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

◆ TEST_P() [5/7]

TEST_P ( Update  ,
UpdateColumnByColumn   
)

Definition at line 1058 of file CtasUpdateTest.cpp.

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

1058  {
1059  // disable if varlen update is not enabled
1060  if (!is_feature_enabled<VarlenUpdates>()) {
1061  LOG(WARNING) << "skipping...";
1062  return;
1063  }
1064 
1065  run_ddl_statement("DROP TABLE IF EXISTS update_test;");
1066 
1067  std::string create_sql = "CREATE TABLE update_test(id int";
1068  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
1069  auto tcd = columnDescriptors[col];
1070 
1071  if (tcd->skip_test("UpdateColumnByColumn")) {
1072  LOG(ERROR) << "not supported... skipping";
1073  return;
1074  }
1075 
1076  create_sql += ", col_src_" + std::to_string(col) + " " + tcd->get_column_definition();
1077  create_sql += ", col_dst_" + std::to_string(col) + " " + tcd->get_column_definition();
1078  }
1079  create_sql += ") WITH (fragment_size=3);";
1080 
1081  LOG(INFO) << create_sql;
1082 
1083  run_ddl_statement(create_sql);
1084 
1085  size_t num_rows = 10;
1086 
1087  // fill source table
1088  for (unsigned int row = 0; row < num_rows; row++) {
1089  std::string insert_sql = "INSERT INTO update_test VALUES (" + std::to_string(row);
1090  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
1091  auto tcd = columnDescriptors[col];
1092  insert_sql += ", " + tcd->get_column_value(row);
1093  insert_sql += ", " + tcd->get_column_value(row + 1);
1094  }
1095  insert_sql += ");";
1096 
1098  }
1099 
1100  // execute Updates
1101  std::string update_sql = "UPDATE update_test set ";
1102  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
1103  update_sql +=
1104  " col_dst_" + std::to_string(col) + "=" + "col_src_" + std::to_string(col);
1105  if (col + 1 < columnDescriptors.size()) {
1106  update_sql += ",";
1107  }
1108  }
1109  update_sql += ";";
1110 
1111  LOG(INFO) << update_sql;
1112 
1114 
1115  // compare source against CTAS
1116  std::string select_sql = "SELECT id";
1117  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
1118  select_sql += ", col_dst_" + std::to_string(col);
1119  select_sql += ", col_src_" + std::to_string(col);
1120  }
1121  select_sql += " FROM update_test ORDER BY id;";
1122 
1123  LOG(INFO) << select_sql;
1124  auto select_result = run_multiple_agg(select_sql, ExecutorDeviceType::CPU);
1125 
1126  for (unsigned int row = 0; row < num_rows; row++) {
1127  const auto select_crt_row = select_result->getNextRow(true, false);
1128 
1129  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
1130  auto tcd = columnDescriptors[col];
1131 
1132  {
1133  const auto mapd_variant = select_crt_row[(2 * col) + 1];
1134  auto mapd_ti = select_result->getColType((2 * col) + 1);
1135  ASSERT_EQ(true, tcd->check_column_value(row, mapd_ti, &mapd_variant));
1136  }
1137  {
1138  const auto mapd_variant = select_crt_row[(2 * col) + 2];
1139  auto mapd_ti = select_result->getColType((2 * col) + 2);
1140  ASSERT_EQ(true, tcd->check_column_value(row, mapd_ti, &mapd_variant));
1141  }
1142  }
1143  }
1144 }
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:

◆ TEST_P() [6/7]

TEST_P ( Update  ,
UpdateColumnByLiteral   
)

Definition at line 1234 of file CtasUpdateTest.cpp.

References updateColumnByLiteralTest().

1234  {
1235  updateColumnByLiteralTest(columnDescriptors, columnDescriptors.size());
1236 }
void updateColumnByLiteralTest(std::vector< std::shared_ptr< TestColumnDescriptor >> &columnDescriptors, size_t numColsToUpdate)
+ Here is the call graph for this function:

◆ TEST_P() [7/7]

TEST_P ( Update  ,
UpdateFirstColumnByLiteral   
)

Definition at line 1238 of file CtasUpdateTest.cpp.

References updateColumnByLiteralTest().

1238  {
1239  if (columnDescriptors.size() > 1) {
1240  updateColumnByLiteralTest(columnDescriptors, 1);
1241  }
1242 }
void updateColumnByLiteralTest(std::vector< std::shared_ptr< TestColumnDescriptor >> &columnDescriptors, size_t numColsToUpdate)
+ 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 
)

◆ updateColumnByLiteralTest()

void updateColumnByLiteralTest ( std::vector< std::shared_ptr< TestColumnDescriptor >> &  columnDescriptors,
size_t  numColsToUpdate 
)

Definition at line 1146 of file CtasUpdateTest.cpp.

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

Referenced by TEST_P().

1148  {
1149  // disable if varlen update is not enabled
1150  if (!is_feature_enabled<VarlenUpdates>()) {
1151  LOG(WARNING) << "skipping...";
1152  return;
1153  }
1154 
1155  run_ddl_statement("DROP TABLE IF EXISTS update_test;");
1156 
1157  std::string create_sql = "CREATE TABLE update_test(id int";
1158  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
1159  auto tcd = columnDescriptors[col];
1160 
1161  if (col < numColsToUpdate) {
1162  if (tcd->skip_test("UpdateColumnByLiteral")) {
1163  LOG(ERROR) << "not supported... skipping";
1164  return;
1165  }
1166  }
1167  create_sql += ", col_dst_" + std::to_string(col) + " " + tcd->get_column_definition();
1168  }
1169  create_sql += ") WITH (fragment_size=3);";
1170 
1171  LOG(INFO) << create_sql;
1172 
1173  run_ddl_statement(create_sql);
1174 
1175  size_t num_rows = 10;
1176 
1177  // fill source table
1178  for (unsigned int row = 0; row < num_rows; row++) {
1179  std::string insert_sql = "INSERT INTO update_test VALUES (" + std::to_string(row);
1180  for (unsigned int col = 0; col < numColsToUpdate; col++) {
1181  auto tcd = columnDescriptors[col];
1182  insert_sql += ", " + tcd->get_column_value(row + 1);
1183  }
1184  for (unsigned int col = numColsToUpdate; col < columnDescriptors.size(); col++) {
1185  auto tcd = columnDescriptors[col];
1186  insert_sql += ", " + tcd->get_column_value(row);
1187  }
1188  insert_sql += ");";
1189 
1191  }
1192 
1193  // execute Updates
1194  for (unsigned int row = 0; row < num_rows; row++) {
1195  std::string update_sql = "UPDATE update_test set ";
1196  for (unsigned int col = 0; col < numColsToUpdate; col++) {
1197  auto tcd = columnDescriptors[col];
1198  update_sql +=
1199  " col_dst_" + std::to_string(col) + "=" + tcd->get_update_column_value(row);
1200  if (col + 1 < numColsToUpdate) {
1201  update_sql += ",";
1202  }
1203  }
1204  update_sql += " WHERE id=" + std::to_string(row) + ";";
1205  LOG(INFO) << update_sql;
1207  }
1208 
1209  // compare source against CTAS
1210  std::string select_sql = "SELECT id";
1211  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
1212  select_sql += ", col_dst_" + std::to_string(col);
1213  }
1214  select_sql += " FROM update_test ORDER BY id;";
1215 
1216  LOG(INFO) << select_sql;
1217  auto select_result = run_multiple_agg(select_sql, ExecutorDeviceType::CPU);
1218 
1219  for (unsigned int row = 0; row < num_rows; row++) {
1220  const auto select_crt_row = select_result->getNextRow(true, false);
1221 
1222  for (unsigned int col = 0; col < columnDescriptors.size(); col++) {
1223  auto tcd = columnDescriptors[col];
1224 
1225  {
1226  const auto mapd_variant = select_crt_row[(1 * col) + 1];
1227  auto mapd_ti = select_result->getColType((1 * col) + 1);
1228  ASSERT_EQ(true, tcd->check_column_value(row, mapd_ti, &mapd_variant));
1229  }
1230  }
1231  }
1232 }
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:

Variable Documentation

◆ ALL

◆ GEO_LINESTRING

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

Definition at line 1409 of file CtasUpdateTest.cpp.

◆ GEO_MULTI_POLYGON

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

Definition at line 1417 of file CtasUpdateTest.cpp.

◆ GEO_POINT

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

Definition at line 1405 of file CtasUpdateTest.cpp.

◆ GEO_POLYGON

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

Definition at line 1413 of file CtasUpdateTest.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 1244 of file CtasUpdateTest.cpp.