OmniSciDB  c07336695a
BooleanColumnDescriptor Class Reference
+ Inheritance diagram for BooleanColumnDescriptor:
+ Collaboration diagram for BooleanColumnDescriptor:

Public Member Functions

 BooleanColumnDescriptor (std::string col_type, SQLTypes sql_type)
 
bool skip_test (std::string name) override
 
std::string get_column_definition () override
 
std::string get_column_value (int row) override
 
bool check_column_value (int row, const TDatum *value) override
 
 BooleanColumnDescriptor (std::string col_type, SQLTypes sql_type)
 
bool skip_test (std::string name) override
 
std::string get_column_definition () override
 
std::string get_column_value (int row) override
 
bool check_column_value (int row, const SQLTypeInfo &type, const ScalarTargetValue *value) override
 
- Public Member Functions inherited from TestColumnDescriptor
virtual std::string get_update_column_value (int row)
 
virtual ~TestColumnDescriptor ()=default
 
virtual std::string get_update_column_value (int row)
 
virtual bool check_column_value (const int row, const SQLTypeInfo &type, const TargetValue *value)
 
virtual ~TestColumnDescriptor ()=default
 

Private Attributes

std::string column_definition
 
SQLTypes rs_type
 

Detailed Description

Definition at line 189 of file CtasIntegrationTest.cpp.

Constructor & Destructor Documentation

◆ BooleanColumnDescriptor() [1/2]

BooleanColumnDescriptor::BooleanColumnDescriptor ( std::string  col_type,
SQLTypes  sql_type 
)
inline

Definition at line 193 of file CtasIntegrationTest.cpp.

194  : column_definition(col_type){};

◆ BooleanColumnDescriptor() [2/2]

BooleanColumnDescriptor::BooleanColumnDescriptor ( std::string  col_type,
SQLTypes  sql_type 
)
inline

Definition at line 139 of file CtasUpdateTest.cpp.

140  : column_definition(col_type), rs_type(sql_type){};

Member Function Documentation

◆ check_column_value() [1/2]

bool BooleanColumnDescriptor::check_column_value ( int  row,
const SQLTypeInfo type,
const ScalarTargetValue value 
)
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 154 of file CtasUpdateTest.cpp.

References logger::ERROR, SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), LOG, NULL_TINYINT, and to_string().

156  {
157  if (type.get_type() != rs_type) {
158  return false;
159  }
160 
161  const auto mapd_as_int_p = boost::get<int64_t>(value);
162  if (nullptr == mapd_as_int_p) {
163  LOG(ERROR) << "row: null";
164  return false;
165  }
166 
167  const auto mapd_val = *mapd_as_int_p;
168 
169  int64_t value_to_check = (row % 2);
170  if (row == 0) {
171  value_to_check = NULL_TINYINT;
172  }
173 
174  if (mapd_val == value_to_check) {
175  return true;
176  }
177 
178  LOG(ERROR) << "row: " << std::to_string(row) << " " << std::to_string(value_to_check)
179  << " vs. " << std::to_string(mapd_val);
180  return false;
181  }
#define LOG(tag)
Definition: Logger.h:182
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:319
std::string to_string(char const *&&v)
#define NULL_TINYINT
Definition: sqltypes.h:172
+ Here is the call graph for this function:

◆ check_column_value() [2/2]

bool BooleanColumnDescriptor::check_column_value ( int  row,
const TDatum *  value 
)
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 210 of file CtasIntegrationTest.cpp.

References checked_get(), logger::ERROR, LOG, NULL_TINYINT, and to_string().

210  {
211  int64_t mapd_val;
212  if (!checked_get(row, value, mapd_val, (int64_t)NULL_TINYINT)) {
213  return false;
214  }
215 
216  int64_t value_to_check = (row % 2);
217  if (row == 0) {
218  value_to_check = NULL_TINYINT;
219  }
220 
221  if (mapd_val == value_to_check) {
222  return true;
223  }
224 
225  LOG(ERROR) << "row: " << std::to_string(row) << " " << std::to_string(value_to_check)
226  << " vs. " << std::to_string(mapd_val);
227  return false;
228  }
#define LOG(tag)
Definition: Logger.h:182
std::string to_string(char const *&&v)
bool checked_get(size_t row, const SOURCE_TYPE *boost_variant, RETURN_TYPE &val, RETURN_TYPE null_value)
#define NULL_TINYINT
Definition: sqltypes.h:172
+ Here is the call graph for this function:

◆ get_column_definition() [1/2]

std::string BooleanColumnDescriptor::get_column_definition ( )
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 146 of file CtasUpdateTest.cpp.

146 { return column_definition; };

◆ get_column_definition() [2/2]

std::string BooleanColumnDescriptor::get_column_definition ( )
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 201 of file CtasIntegrationTest.cpp.

201 { return column_definition; };

◆ get_column_value() [1/2]

std::string BooleanColumnDescriptor::get_column_value ( int  row)
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 147 of file CtasUpdateTest.cpp.

147  {
148  if (0 == row) {
149  return "null";
150  }
151 
152  return (row % 2) ? "'true'" : "'false'";
153  };

◆ get_column_value() [2/2]

std::string BooleanColumnDescriptor::get_column_value ( int  row)
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 202 of file CtasIntegrationTest.cpp.

202  {
203  if (0 == row) {
204  return "null";
205  }
206 
207  return (row % 2) ? "'true'" : "'false'";
208  };

◆ skip_test() [1/2]

bool BooleanColumnDescriptor::skip_test ( std::string  name)
inlineoverridevirtual

Reimplemented from TestColumnDescriptor.

Definition at line 142 of file CtasUpdateTest.cpp.

142  {
143  return "UpdateColumnByLiteral" == name || "Array.UpdateColumnByLiteral" == name;
144  }

◆ skip_test() [2/2]

bool BooleanColumnDescriptor::skip_test ( std::string  name)
inlineoverridevirtual

Reimplemented from TestColumnDescriptor.

Definition at line 196 of file CtasIntegrationTest.cpp.

196  {
197  return "UpdateColumnByColumn" == name || "UpdateColumnByLiteral" == name ||
198  "Array.UpdateColumnByLiteral" == name;
199  }

Member Data Documentation

◆ column_definition

std::string BooleanColumnDescriptor::column_definition
private

Definition at line 190 of file CtasIntegrationTest.cpp.

◆ rs_type

SQLTypes BooleanColumnDescriptor::rs_type
private

Definition at line 136 of file CtasUpdateTest.cpp.


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