OmniSciDB  04ee39c94c
DateTimeColumnDescriptor Class Reference
+ Inheritance diagram for DateTimeColumnDescriptor:
+ Collaboration diagram for DateTimeColumnDescriptor:

Public Member Functions

 DateTimeColumnDescriptor (std::string col_type, SQLTypes sql_type, std::string fmt, long offset, int scale)
 
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
 
std::string getValueAsString (int row)
 
 DateTimeColumnDescriptor (std::string col_type, SQLTypes sql_type, std::string fmt, long offset, int scale)
 
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
 
std::string getValueAsString (int row)
 
- 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
 
std::string format
 
long offset
 
long scale
 

Detailed Description

Definition at line 272 of file CtasIntegrationTest.cpp.

Constructor & Destructor Documentation

◆ DateTimeColumnDescriptor() [1/2]

DateTimeColumnDescriptor::DateTimeColumnDescriptor ( std::string  col_type,
SQLTypes  sql_type,
std::string  fmt,
long  offset,
int  scale 
)
inline

Definition at line 280 of file CtasIntegrationTest.cpp.

◆ DateTimeColumnDescriptor() [2/2]

DateTimeColumnDescriptor::DateTimeColumnDescriptor ( std::string  col_type,
SQLTypes  sql_type,
std::string  fmt,
long  offset,
int  scale 
)
inline

Definition at line 245 of file CtasUpdateTest.cpp.

Member Function Documentation

◆ check_column_value() [1/2]

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

Implements TestColumnDescriptor.

Definition at line 268 of file CtasUpdateTest.cpp.

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

270  {
271  if (type.get_type() != rs_type) {
272  return false;
273  }
274 
275  const auto mapd_as_int_p = boost::get<int64_t>(value);
276  if (nullptr == mapd_as_int_p) {
277  return 0 == row;
278  }
279 
280  const auto mapd_val = *mapd_as_int_p;
281 
282  int64_t value_to_check = (offset + (scale * row));
283  if (rs_type == kDATE) {
284  value_to_check /= (24 * 60 * 60);
285  value_to_check *= (24 * 60 * 60);
286  }
287  if (row == 0) {
288  value_to_check = NULL_BIGINT;
289  }
290 
291  if (mapd_val == value_to_check) {
292  return true;
293  }
294 
295  LOG(ERROR) << "row: " << std::to_string(row) << " "
296  << std::to_string((offset + (scale * row))) << " vs. "
297  << std::to_string(mapd_val);
298  return false;
299  }
#define NULL_BIGINT
Definition: sqltypes.h:174
#define LOG(tag)
Definition: Logger.h:182
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:323
std::string to_string(char const *&&v)
Definition: sqltypes.h:55
+ Here is the call graph for this function:

◆ check_column_value() [2/2]

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

Implements TestColumnDescriptor.

Definition at line 303 of file CtasIntegrationTest.cpp.

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

303  {
304  int64_t mapd_val;
305 
306  if (!checked_get(row, value, mapd_val, NULL_BIGINT)) {
307  return 0 == row;
308  }
309 
310  int64_t value_to_check = (offset + (scale * row));
311  if (rs_type == kDATE) {
312  value_to_check /= (24 * 60 * 60);
313  value_to_check *= (24 * 60 * 60);
314  }
315  if (row == 0) {
316  value_to_check = NULL_BIGINT;
317  }
318 
319  if (mapd_val == value_to_check) {
320  return true;
321  }
322 
323  LOG(ERROR) << "row: " << std::to_string(row) << " "
324  << std::to_string((offset + (scale * row))) << " vs. "
325  << std::to_string(mapd_val);
326  return false;
327  }
#define NULL_BIGINT
Definition: sqltypes.h:174
#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)
Definition: sqltypes.h:55
+ Here is the call graph for this function:

◆ get_column_definition() [1/2]

std::string DateTimeColumnDescriptor::get_column_definition ( )
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 260 of file CtasUpdateTest.cpp.

260 { return column_definition; };

◆ get_column_definition() [2/2]

std::string DateTimeColumnDescriptor::get_column_definition ( )
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 295 of file CtasIntegrationTest.cpp.

295 { return column_definition; };

◆ get_column_value() [1/2]

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

Implements TestColumnDescriptor.

Definition at line 261 of file CtasUpdateTest.cpp.

261  {
262  if (0 == row) {
263  return "null";
264  }
265 
266  return "'" + getValueAsString(row) + "'";
267  };
std::string getValueAsString(int row)

◆ get_column_value() [2/2]

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

Implements TestColumnDescriptor.

Definition at line 296 of file CtasIntegrationTest.cpp.

296  {
297  if (0 == row) {
298  return "null";
299  }
300 
301  return "'" + getValueAsString(row) + "'";
302  };
std::string getValueAsString(int row)

◆ getValueAsString() [1/2]

std::string DateTimeColumnDescriptor::getValueAsString ( int  row)
inline

Definition at line 301 of file CtasUpdateTest.cpp.

301  {
302  std::tm tm_struct;
303  time_t t = offset + (scale * row);
304  gmtime_r(&t, &tm_struct);
305  char buf[128];
306  strftime(buf, 128, format.c_str(), &tm_struct);
307  return std::string(buf);
308  }

◆ getValueAsString() [2/2]

std::string DateTimeColumnDescriptor::getValueAsString ( int  row)
inline

Definition at line 329 of file CtasIntegrationTest.cpp.

329  {
330  std::tm tm_struct;
331  time_t t = offset + (scale * row);
332  gmtime_r(&t, &tm_struct);
333  char buf[128];
334  strftime(buf, 128, format.c_str(), &tm_struct);
335  return std::string(buf);
336  }

◆ skip_test() [1/2]

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

Reimplemented from TestColumnDescriptor.

Definition at line 256 of file CtasUpdateTest.cpp.

256  {
257  return "Array.UpdateColumnByLiteral" == name;
258  }

◆ skip_test() [2/2]

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

Reimplemented from TestColumnDescriptor.

Definition at line 291 of file CtasIntegrationTest.cpp.

291  {
292  return "Array.UpdateColumnByLiteral" == name;
293  }

Member Data Documentation

◆ column_definition

std::string DateTimeColumnDescriptor::column_definition
private

Definition at line 273 of file CtasIntegrationTest.cpp.

◆ format

std::string DateTimeColumnDescriptor::format
private

Definition at line 275 of file CtasIntegrationTest.cpp.

◆ offset

long DateTimeColumnDescriptor::offset
private

Definition at line 276 of file CtasIntegrationTest.cpp.

◆ rs_type

SQLTypes DateTimeColumnDescriptor::rs_type
private

Definition at line 274 of file CtasIntegrationTest.cpp.

◆ scale

long DateTimeColumnDescriptor::scale
private

Definition at line 277 of file CtasIntegrationTest.cpp.


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