OmniSciDB  04ee39c94c
ComputeMetadataTest.cpp File Reference
#include "TestHelpers.h"
#include "../Catalog/Catalog.h"
#include "../QueryEngine/Execute.h"
#include "../QueryEngine/TableOptimizer.h"
#include "../QueryRunner/QueryRunner.h"
#include <gtest/gtest.h>
#include <string>
#include <utility>
+ Include dependency graph for ComputeMetadataTest.cpp:

Go to the source code of this file.

Classes

class  MultiFragMetadataUpdate
 
class  MetadataUpdate< NSHARDS >
 

Namespaces

 

Macros

#define BASE_PATH   "./tmp"
 
#define ASSERT_METADATA(type, tag)
 
#define BODY_F(test_class, test_name)   test_class##_##test_name##_body()
 
#define TEST_F1(test_class, test_name, sharded_or_not)   TEST_F(test_class##_##sharded_or_not, test_name) { BODY_F(test_class, test_name); }
 
#define TEST_UNSHARDED_AND_SHARDED(test_class, test_name)
 

Typedefs

using QR = QueryRunner::QueryRunner
 
using MetadataUpdate_Unsharded = MetadataUpdate< 1 >
 
using MetadataUpdate_Sharded = MetadataUpdate< 4 >
 

Functions

void anonymous_namespace{ComputeMetadataTest.cpp}::run_ddl_statement (const std::string &stmt)
 
std::shared_ptr< ResultSetanonymous_namespace{ComputeMetadataTest.cpp}::run_multiple_agg (const std::string &query_str, const ExecutorDeviceType device_type)
 
template<typename T , typename... Args>
void anonymous_namespace{ComputeMetadataTest.cpp}::check_column_metadata_impl (const std::map< int, ChunkMetadata > &metadata_map, const int column_idx, const T min, const T max, const bool has_nulls)
 
template<typename T , typename... Args>
void anonymous_namespace{ComputeMetadataTest.cpp}::check_column_metadata_impl (const std::map< int, ChunkMetadata > &metadata_map, const int column_idx, const T min, const T max, const bool has_nulls, Args &&... args)
 
template<typename... Args>
auto anonymous_namespace{ComputeMetadataTest.cpp}::check_fragment_metadata (Args &&... args) -> auto
 
template<typename FUNC , typename... Args>
void anonymous_namespace{ComputeMetadataTest.cpp}::run_op_per_fragment (const TableDescriptor *td, FUNC f, Args &&... args)
 
template<typename FUNC , typename... Args, std::size_t... Is>
void anonymous_namespace{ComputeMetadataTest.cpp}::run_op_per_fragment (const TableDescriptor *td, FUNC f, std::tuple< Args... > tuple, std::index_sequence< Is... >)
 
template<typename FUNC , typename... Args>
void anonymous_namespace{ComputeMetadataTest.cpp}::run_op_per_fragment (const TableDescriptor *td, std::tuple< FUNC, std::tuple< Args... >> tuple)
 
void anonymous_namespace{ComputeMetadataTest.cpp}::recompute_metadata (const TableDescriptor *td, const Catalog_Namespace::Catalog &cat)
 
void anonymous_namespace{ComputeMetadataTest.cpp}::vacuum_and_recompute_metadata (const TableDescriptor *td, const Catalog_Namespace::Catalog &cat)
 
 TEST_F (MultiFragMetadataUpdate, NoChanges)
 
void BODY_F (MetadataUpdate, InitialMetadata)
 
void BODY_F (MetadataUpdate, IntUpdate)
 
void BODY_F (MetadataUpdate, IntRemoveNull)
 
void BODY_F (MetadataUpdate, NotNullInt)
 
void BODY_F (MetadataUpdate, DateNarrowRange)
 
void BODY_F (MetadataUpdate, SmallDateNarrowMin)
 
void BODY_F (MetadataUpdate, SmallDateNarrowMax)
 
void BODY_F (MetadataUpdate, DeleteReset)
 
void BODY_F (MetadataUpdate, EncodedStringNull)
 
void BODY_F (MetadataUpdate, AlterAfterOptimize)
 
void BODY_F (MetadataUpdate, AlterAfterEmptied)
 
int main (int argc, char **argv)
 

Variables

template<typename... Args>
auto anonymous_namespace{ComputeMetadataTest.cpp}::check_column_metadata
 
static const std::string anonymous_namespace{ComputeMetadataTest.cpp}::g_table_name {"metadata_test"}
 

Macro Definition Documentation

◆ ASSERT_METADATA

#define ASSERT_METADATA (   type,
  tag 
)
Value:
template <typename T, bool enabled = std::is_same<T, type>::value> \
void assert_metadata(const ChunkStats& chunkStats, \
const T min, \
const T max, \
const bool has_nulls, \
const std::enable_if_t<enabled, type>* = 0) { \
ASSERT_EQ(chunkStats.min.tag##val, min); \
ASSERT_EQ(chunkStats.max.tag##val, max); \
ASSERT_EQ(chunkStats.has_nulls, has_nulls); \
}
bool has_nulls
Definition: ChunkMetadata.h:28

Definition at line 45 of file ComputeMetadataTest.cpp.

◆ BASE_PATH

#define BASE_PATH   "./tmp"

Definition at line 29 of file ComputeMetadataTest.cpp.

Referenced by main().

◆ BODY_F

#define BODY_F (   test_class,
  test_name 
)    test_class##_##test_name##_body()

Definition at line 294 of file ComputeMetadataTest.cpp.

◆ TEST_F1

#define TEST_F1 (   test_class,
  test_name,
  sharded_or_not 
)    TEST_F(test_class##_##sharded_or_not, test_name) { BODY_F(test_class, test_name); }

Definition at line 295 of file ComputeMetadataTest.cpp.

◆ TEST_UNSHARDED_AND_SHARDED

#define TEST_UNSHARDED_AND_SHARDED (   test_class,
  test_name 
)
Value:
TEST_F1(test_class, test_name, Unsharded) \
TEST_F1(test_class, test_name, Sharded)
#define TEST_F1(test_class, test_name, sharded_or_not)

Definition at line 297 of file ComputeMetadataTest.cpp.

Referenced by BODY_F().

Typedef Documentation

◆ MetadataUpdate_Sharded

Definition at line 292 of file ComputeMetadataTest.cpp.

◆ MetadataUpdate_Unsharded

Definition at line 291 of file ComputeMetadataTest.cpp.

◆ QR

Definition at line 32 of file ComputeMetadataTest.cpp.

Function Documentation

◆ BODY_F() [1/11]

void BODY_F ( MetadataUpdate  ,
InitialMetadata   
)

Definition at line 301 of file ComputeMetadataTest.cpp.

References anonymous_namespace{ComputeMetadataTest.cpp}::check_fragment_metadata(), anonymous_namespace{ComputeMetadataTest.cpp}::g_table_name, QueryRunner::QueryRunner::get(), QueryRunner::QueryRunner::getCatalog(), and anonymous_namespace{ComputeMetadataTest.cpp}::run_op_per_fragment().

301  {
302  const auto cat = QR::get()->getCatalog();
303  const auto td = cat->getMetadataForTable(g_table_name, /*populateFragmenter=*/true);
304 
306  td,
308  // Check int col: expected range 1,2 nulls
309  /* id = */ 1,
310  /* min = */ 1,
311  /* max = 2 */ 2,
312  /* has_nulls = */ true,
313 
314  // Check int not null col: expected range 1,2 no nulls
315  2,
316  1,
317  2,
318  false,
319 
320  // Check int encoded call: expected range 1,2 nulls
321  3,
322  1,
323  2,
324  true,
325 
326  // Check double col: expected range 1.0,2.0 nulls
327  4,
328  (double)1.0,
329  2.0,
330  true,
331 
332  // Check float col: expected range 1.0,2.0 nulls
333  5,
334  (float)1.0,
335  2.0,
336  true,
337 
338  // Check date in days 32 col: expected range 1262304000,1356912000 nulls
339  6,
340  1262304000,
341  1356912000,
342  true,
343 
344  // Check date in days 16 col: expected range -946771200,1356912000 nulls
345  7,
346  -946771200,
347  1356912000,
348  false,
349 
350  // Check col c TEXT ENCODING DICT(32): expected range [0, 0]
351  8,
352  0,
353  0,
354  false));
355 }
std::shared_ptr< Catalog_Namespace::Catalog > getCatalog() const
static QueryRunner * get()
Definition: QueryRunner.h:115
void run_op_per_fragment(const TableDescriptor *td, std::tuple< FUNC, std::tuple< Args... >> tuple)
auto check_fragment_metadata(Args &&... args) -> auto
+ Here is the call graph for this function:

◆ BODY_F() [2/11]

void BODY_F ( MetadataUpdate  ,
IntUpdate   
)

Definition at line 357 of file ComputeMetadataTest.cpp.

References anonymous_namespace{ComputeMetadataTest.cpp}::check_fragment_metadata(), CPU, anonymous_namespace{ComputeMetadataTest.cpp}::g_table_name, QueryRunner::QueryRunner::get(), QueryRunner::QueryRunner::getCatalog(), anonymous_namespace{ComputeMetadataTest.cpp}::recompute_metadata(), run_multiple_agg(), and anonymous_namespace{ComputeMetadataTest.cpp}::run_op_per_fragment().

357  {
358  const auto cat = QR::get()->getCatalog();
359  const auto td = cat->getMetadataForTable(g_table_name, /*populateFragmenter=*/true);
360 
361  run_multiple_agg("UPDATE " + g_table_name + " SET x = 3 WHERE x = 1;",
363 
364  // Check int col: expected range 1,3 nulls
365  run_op_per_fragment(td, check_fragment_metadata(1, (int32_t)1, 3, true));
366 
367  run_multiple_agg("UPDATE " + g_table_name + " SET x = 0 WHERE x = 3;",
369 
370  recompute_metadata(td, *cat);
371  // Check int col: expected range 1,2 nulls
372  run_op_per_fragment(td, check_fragment_metadata(1, (int32_t)0, 2, true));
373 }
std::shared_ptr< Catalog_Namespace::Catalog > getCatalog() const
static QueryRunner * get()
Definition: QueryRunner.h:115
void run_op_per_fragment(const TableDescriptor *td, std::tuple< FUNC, std::tuple< Args... >> tuple)
void recompute_metadata(const TableDescriptor *td, const Catalog_Namespace::Catalog &cat)
auto check_fragment_metadata(Args &&... args) -> auto
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

◆ BODY_F() [3/11]

void BODY_F ( MetadataUpdate  ,
IntRemoveNull   
)

Definition at line 375 of file ComputeMetadataTest.cpp.

References anonymous_namespace{ComputeMetadataTest.cpp}::check_fragment_metadata(), CPU, anonymous_namespace{ComputeMetadataTest.cpp}::g_table_name, QueryRunner::QueryRunner::get(), QueryRunner::QueryRunner::getCatalog(), anonymous_namespace{ComputeMetadataTest.cpp}::recompute_metadata(), run_multiple_agg(), and anonymous_namespace{ComputeMetadataTest.cpp}::run_op_per_fragment().

375  {
376  const auto cat = QR::get()->getCatalog();
377  const auto td = cat->getMetadataForTable(g_table_name, /*populateFragmenter=*/true);
378 
379  run_multiple_agg("UPDATE " + g_table_name + " SET x = 3;", ExecutorDeviceType::CPU);
380 
381  recompute_metadata(td, *cat);
382  // Check int col: expected range 1,2 nulls
383  run_op_per_fragment(td, check_fragment_metadata(1, (int32_t)3, 3, false));
384 }
std::shared_ptr< Catalog_Namespace::Catalog > getCatalog() const
static QueryRunner * get()
Definition: QueryRunner.h:115
void run_op_per_fragment(const TableDescriptor *td, std::tuple< FUNC, std::tuple< Args... >> tuple)
void recompute_metadata(const TableDescriptor *td, const Catalog_Namespace::Catalog &cat)
auto check_fragment_metadata(Args &&... args) -> auto
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

◆ BODY_F() [4/11]

void BODY_F ( MetadataUpdate  ,
NotNullInt   
)

Definition at line 386 of file ComputeMetadataTest.cpp.

References anonymous_namespace{ComputeMetadataTest.cpp}::check_fragment_metadata(), CPU, anonymous_namespace{ComputeMetadataTest.cpp}::g_table_name, QueryRunner::QueryRunner::get(), QueryRunner::QueryRunner::getCatalog(), anonymous_namespace{ComputeMetadataTest.cpp}::recompute_metadata(), run_multiple_agg(), anonymous_namespace{ComputeMetadataTest.cpp}::run_op_per_fragment(), and to_string().

386  {
387  const auto cat = QR::get()->getCatalog();
388  const auto td = cat->getMetadataForTable(g_table_name, /*populateFragmenter=*/true);
389 
390  run_multiple_agg("UPDATE " + g_table_name + " SET y = " +
391  std::to_string(std::numeric_limits<int32_t>::lowest() + 1) +
392  " WHERE y = 1;",
394  // Check int col: expected range 1,3 nulls
396  td,
397  check_fragment_metadata(2, std::numeric_limits<int32_t>::lowest() + 1, 2, false));
398 
399  run_multiple_agg("UPDATE " + g_table_name + " SET y = 1;", ExecutorDeviceType::CPU);
400 
401  recompute_metadata(td, *cat);
402  run_op_per_fragment(td, check_fragment_metadata(2, (int32_t)1, 1, false));
403 }
std::string to_string(char const *&&v)
std::shared_ptr< Catalog_Namespace::Catalog > getCatalog() const
static QueryRunner * get()
Definition: QueryRunner.h:115
void run_op_per_fragment(const TableDescriptor *td, std::tuple< FUNC, std::tuple< Args... >> tuple)
void recompute_metadata(const TableDescriptor *td, const Catalog_Namespace::Catalog &cat)
auto check_fragment_metadata(Args &&... args) -> auto
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

◆ BODY_F() [5/11]

void BODY_F ( MetadataUpdate  ,
DateNarrowRange   
)

Definition at line 405 of file ComputeMetadataTest.cpp.

References anonymous_namespace{ComputeMetadataTest.cpp}::check_fragment_metadata(), CPU, anonymous_namespace{ComputeMetadataTest.cpp}::g_table_name, QueryRunner::QueryRunner::get(), QueryRunner::QueryRunner::getCatalog(), anonymous_namespace{ComputeMetadataTest.cpp}::recompute_metadata(), run_multiple_agg(), and anonymous_namespace{ComputeMetadataTest.cpp}::run_op_per_fragment().

405  {
406  const auto cat = QR::get()->getCatalog();
407  const auto td = cat->getMetadataForTable(g_table_name, /*populateFragmenter=*/true);
408 
409  run_multiple_agg("UPDATE " + g_table_name + " SET d = '1/1/2010';",
411 
412  recompute_metadata(td, *cat);
413  // Check date in days 32 col: expected range 1262304000,1262304000 nulls
415  check_fragment_metadata(6, (int64_t)1262304000, 1262304000, false));
416 }
std::shared_ptr< Catalog_Namespace::Catalog > getCatalog() const
static QueryRunner * get()
Definition: QueryRunner.h:115
void run_op_per_fragment(const TableDescriptor *td, std::tuple< FUNC, std::tuple< Args... >> tuple)
void recompute_metadata(const TableDescriptor *td, const Catalog_Namespace::Catalog &cat)
auto check_fragment_metadata(Args &&... args) -> auto
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

◆ BODY_F() [6/11]

void BODY_F ( MetadataUpdate  ,
SmallDateNarrowMin   
)

Definition at line 418 of file ComputeMetadataTest.cpp.

References anonymous_namespace{ComputeMetadataTest.cpp}::check_fragment_metadata(), CPU, anonymous_namespace{ComputeMetadataTest.cpp}::g_table_name, QueryRunner::QueryRunner::get(), QueryRunner::QueryRunner::getCatalog(), anonymous_namespace{ComputeMetadataTest.cpp}::recompute_metadata(), run_multiple_agg(), and anonymous_namespace{ComputeMetadataTest.cpp}::run_op_per_fragment().

418  {
419  const auto cat = QR::get()->getCatalog();
420  const auto td = cat->getMetadataForTable(g_table_name, /*populateFragmenter=*/true);
421 
423  "UPDATE " + g_table_name + " SET dd = '1/1/2010' WHERE dd = '1/1/1940';",
425 
426  recompute_metadata(td, *cat);
428  check_fragment_metadata(7, (int64_t)1262304000, 1356912000, false));
429 }
std::shared_ptr< Catalog_Namespace::Catalog > getCatalog() const
static QueryRunner * get()
Definition: QueryRunner.h:115
void run_op_per_fragment(const TableDescriptor *td, std::tuple< FUNC, std::tuple< Args... >> tuple)
void recompute_metadata(const TableDescriptor *td, const Catalog_Namespace::Catalog &cat)
auto check_fragment_metadata(Args &&... args) -> auto
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

◆ BODY_F() [7/11]

void BODY_F ( MetadataUpdate  ,
SmallDateNarrowMax   
)

Definition at line 431 of file ComputeMetadataTest.cpp.

References anonymous_namespace{ComputeMetadataTest.cpp}::check_fragment_metadata(), CPU, anonymous_namespace{ComputeMetadataTest.cpp}::g_table_name, QueryRunner::QueryRunner::get(), QueryRunner::QueryRunner::getCatalog(), anonymous_namespace{ComputeMetadataTest.cpp}::recompute_metadata(), run_multiple_agg(), and anonymous_namespace{ComputeMetadataTest.cpp}::run_op_per_fragment().

431  {
432  const auto cat = QR::get()->getCatalog();
433  const auto td = cat->getMetadataForTable(g_table_name, /*populateFragmenter=*/true);
434 
436  "UPDATE " + g_table_name + " SET dd = '1/1/2010' WHERE dd = '12/31/2012';",
438 
439  recompute_metadata(td, *cat);
441  check_fragment_metadata(7, (int64_t)-946771200, 1262304000, false));
442 }
std::shared_ptr< Catalog_Namespace::Catalog > getCatalog() const
static QueryRunner * get()
Definition: QueryRunner.h:115
void run_op_per_fragment(const TableDescriptor *td, std::tuple< FUNC, std::tuple< Args... >> tuple)
void recompute_metadata(const TableDescriptor *td, const Catalog_Namespace::Catalog &cat)
auto check_fragment_metadata(Args &&... args) -> auto
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

◆ BODY_F() [8/11]

void BODY_F ( MetadataUpdate  ,
DeleteReset   
)

Definition at line 444 of file ComputeMetadataTest.cpp.

References anonymous_namespace{ComputeMetadataTest.cpp}::check_fragment_metadata(), CPU, anonymous_namespace{ComputeMetadataTest.cpp}::g_table_name, QueryRunner::QueryRunner::get(), QueryRunner::QueryRunner::getCatalog(), run_multiple_agg(), anonymous_namespace{ComputeMetadataTest.cpp}::run_op_per_fragment(), and anonymous_namespace{ComputeMetadataTest.cpp}::vacuum_and_recompute_metadata().

444  {
445  const auto cat = QR::get()->getCatalog();
446  const auto td = cat->getMetadataForTable(g_table_name, /*populateFragmenter=*/true);
447 
448  run_multiple_agg("DELETE FROM " + g_table_name + " WHERE dd = '12/31/2012';",
450  run_op_per_fragment(td, check_fragment_metadata(-1, false, true, false));
451 
453  run_op_per_fragment(td, check_fragment_metadata(-1, false, false, false));
454 }
std::shared_ptr< Catalog_Namespace::Catalog > getCatalog() const
static QueryRunner * get()
Definition: QueryRunner.h:115
void run_op_per_fragment(const TableDescriptor *td, std::tuple< FUNC, std::tuple< Args... >> tuple)
void vacuum_and_recompute_metadata(const TableDescriptor *td, const Catalog_Namespace::Catalog &cat)
auto check_fragment_metadata(Args &&... args) -> auto
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

◆ BODY_F() [9/11]

void BODY_F ( MetadataUpdate  ,
EncodedStringNull   
)

Definition at line 456 of file ComputeMetadataTest.cpp.

References anonymous_namespace{ComputeMetadataTest.cpp}::check_fragment_metadata(), CPU, anonymous_namespace{ComputeMetadataTest.cpp}::g_table_name, QueryRunner::QueryRunner::get(), QueryRunner::QueryRunner::getCatalog(), run_multiple_agg(), anonymous_namespace{ComputeMetadataTest.cpp}::run_op_per_fragment(), and anonymous_namespace{ComputeMetadataTest.cpp}::vacuum_and_recompute_metadata().

456  {
457  const auto cat = QR::get()->getCatalog();
458  const auto td = cat->getMetadataForTable(g_table_name, /*populateFragmenter=*/true);
459 
461  for (int sh = 0; sh < std::max(1, td->nShards); ++sh) {
462  run_multiple_agg(gen(1, 1, 1, 1, 1, "'1/1/2010'", "'1/1/2010'", "'abc'", sh),
464  }
466  run_op_per_fragment(td, check_fragment_metadata(8, 0, 1, false));
467 
468  for (int sh = 0; sh < std::max(1, td->nShards); ++sh) {
469  run_multiple_agg(gen(1, 1, 1, 1, 1, "'1/1/2010'", "'1/1/2010'", "null", sh),
471  }
473  run_op_per_fragment(td, check_fragment_metadata(8, 0, 1, true));
474 }
std::shared_ptr< Catalog_Namespace::Catalog > getCatalog() const
static QueryRunner * get()
Definition: QueryRunner.h:115
void run_op_per_fragment(const TableDescriptor *td, std::tuple< FUNC, std::tuple< Args... >> tuple)
void vacuum_and_recompute_metadata(const TableDescriptor *td, const Catalog_Namespace::Catalog &cat)
auto check_fragment_metadata(Args &&... args) -> auto
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

◆ BODY_F() [10/11]

void BODY_F ( MetadataUpdate  ,
AlterAfterOptimize   
)

Definition at line 476 of file ComputeMetadataTest.cpp.

References anonymous_namespace{ComputeMetadataTest.cpp}::check_fragment_metadata(), CPU, anonymous_namespace{ComputeMetadataTest.cpp}::g_table_name, QueryRunner::QueryRunner::get(), QueryRunner::QueryRunner::getCatalog(), run_ddl_statement(), run_multiple_agg(), anonymous_namespace{ComputeMetadataTest.cpp}::run_op_per_fragment(), and anonymous_namespace{ComputeMetadataTest.cpp}::vacuum_and_recompute_metadata().

476  {
477  const auto cat = QR::get()->getCatalog();
478  const auto td = cat->getMetadataForTable(g_table_name, /*populateFragmenter=*/true);
479  run_op_per_fragment(td, check_fragment_metadata(1, 1, 2, true));
480  run_multiple_agg("DELETE FROM " + g_table_name + " WHERE x IS NULL;",
483  run_op_per_fragment(td, check_fragment_metadata(1, 1, 2, false));
484  // test ADD one column
485  EXPECT_NO_THROW(
486  run_ddl_statement("ALTER TABLE " + g_table_name + " ADD (c99 int default 99);"));
487  run_op_per_fragment(td, check_fragment_metadata(12, 99, 99, false));
488  // test ADD multiple columns
489  EXPECT_NO_THROW(run_ddl_statement("ALTER TABLE " + g_table_name +
490  " ADD (c88 int default 88, cnn int);"));
491  run_op_per_fragment(td, check_fragment_metadata(13, 88, 88, false));
494  std::numeric_limits<int32_t>::max(),
495  std::numeric_limits<int32_t>::lowest(),
496  true));
497 }
std::shared_ptr< Catalog_Namespace::Catalog > getCatalog() const
static QueryRunner * get()
Definition: QueryRunner.h:115
void run_op_per_fragment(const TableDescriptor *td, std::tuple< FUNC, std::tuple< Args... >> tuple)
void vacuum_and_recompute_metadata(const TableDescriptor *td, const Catalog_Namespace::Catalog &cat)
void run_ddl_statement(std::string ddl)
auto check_fragment_metadata(Args &&... args) -> auto
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

◆ BODY_F() [11/11]

void BODY_F ( MetadataUpdate  ,
AlterAfterEmptied   
)

Definition at line 499 of file ComputeMetadataTest.cpp.

References anonymous_namespace{ComputeMetadataTest.cpp}::check_fragment_metadata(), CPU, anonymous_namespace{ComputeMetadataTest.cpp}::g_table_name, QueryRunner::QueryRunner::get(), QueryRunner::QueryRunner::getCatalog(), run_ddl_statement(), run_multiple_agg(), anonymous_namespace{ComputeMetadataTest.cpp}::run_op_per_fragment(), TEST_UNSHARDED_AND_SHARDED, and anonymous_namespace{ComputeMetadataTest.cpp}::vacuum_and_recompute_metadata().

499  {
500  const auto cat = QR::get()->getCatalog();
501  const auto td = cat->getMetadataForTable(g_table_name, /*populateFragmenter=*/true);
502  run_multiple_agg("DELETE FROM " + g_table_name + ";", ExecutorDeviceType::CPU);
506  std::numeric_limits<int32_t>::max(),
507  std::numeric_limits<int32_t>::lowest(),
508  false));
509  // test ADD one column to make sure column is added even if no row exists
510  EXPECT_NO_THROW(
511  run_ddl_statement("ALTER TABLE " + g_table_name + " ADD (c99 int default 99);"));
514  std::numeric_limits<int32_t>::max(),
515  std::numeric_limits<int32_t>::lowest(),
516  true));
517  // test ADD multiple columns
518  EXPECT_NO_THROW(run_ddl_statement("ALTER TABLE " + g_table_name +
519  " ADD (c88 int default 88, cnn int);"));
520  run_op_per_fragment(td, check_fragment_metadata(13, 88, 88, false));
523  std::numeric_limits<int32_t>::max(),
524  std::numeric_limits<int32_t>::lowest(),
525  true));
526 }
std::shared_ptr< Catalog_Namespace::Catalog > getCatalog() const
static QueryRunner * get()
Definition: QueryRunner.h:115
void run_op_per_fragment(const TableDescriptor *td, std::tuple< FUNC, std::tuple< Args... >> tuple)
void vacuum_and_recompute_metadata(const TableDescriptor *td, const Catalog_Namespace::Catalog &cat)
void run_ddl_statement(std::string ddl)
auto check_fragment_metadata(Args &&... args) -> auto
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 539 of file ComputeMetadataTest.cpp.

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

539  {
541  testing::InitGoogleTest(&argc, argv);
542 
544 
545  int err{0};
546  try {
547  err = RUN_ALL_TESTS();
548  } catch (const std::exception& e) {
549  LOG(ERROR) << e.what();
550  }
551  QR::reset();
552  return err;
553 }
#define LOG(tag)
Definition: Logger.h:182
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
#define BASE_PATH
void init_logger_stderr_only(int argc, char const *const *argv)
Definition: TestHelpers.h:194
+ Here is the call graph for this function:

◆ TEST_F()

TEST_F ( MultiFragMetadataUpdate  ,
NoChanges   
)

Definition at line 223 of file ComputeMetadataTest.cpp.

References CHECK, anonymous_namespace{ComputeMetadataTest.cpp}::g_table_name, QueryRunner::QueryRunner::get(), QueryRunner::QueryRunner::getCatalog(), anonymous_namespace{ComputeMetadataTest.cpp}::recompute_metadata(), and anonymous_namespace{ComputeMetadataTest.cpp}::run_op_per_fragment().

223  {
224  std::vector<std::map<int, ChunkMetadata>> metadata_for_fragments;
225  {
226  const auto cat = QR::get()->getCatalog();
227  const auto td = cat->getMetadataForTable(g_table_name, /*populateFragmenter=*/true);
228 
229  // Get chunk metadata before recomputing
230  auto store_original_metadata =
231  [&metadata_for_fragments](const Fragmenter_Namespace::FragmentInfo& fragment) {
232  metadata_for_fragments.push_back(fragment.getChunkMetadataMapPhysical());
233  };
234 
235  run_op_per_fragment(td, store_original_metadata);
236  recompute_metadata(td, *cat);
237  }
238 
239  // Make sure metadata matches after recomputing
240  {
241  const auto cat = QR::get()->getCatalog();
242  const auto td = cat->getMetadataForTable(g_table_name, /*populateFragmenter=*/true);
243 
244  auto* fragmenter = td->fragmenter;
245  CHECK(fragmenter);
246  const auto table_info = fragmenter->getFragmentsForQuery();
247 
248  size_t ctr = 0;
249  auto check_metadata_equality =
250  [&ctr,
251  &metadata_for_fragments](const Fragmenter_Namespace::FragmentInfo& fragment) {
252  ASSERT_LT(ctr, metadata_for_fragments.size());
253  ASSERT_TRUE(metadata_for_fragments[ctr++] ==
254  fragment.getChunkMetadataMapPhysical());
255  };
256  run_op_per_fragment(td, check_metadata_equality);
257  }
258 }
Used by Fragmenter classes to store info about each fragment - the fragment id and number of tuples(r...
Definition: Fragmenter.h:79
std::shared_ptr< Catalog_Namespace::Catalog > getCatalog() const
static QueryRunner * get()
Definition: QueryRunner.h:115
void run_op_per_fragment(const TableDescriptor *td, std::tuple< FUNC, std::tuple< Args... >> tuple)
void recompute_metadata(const TableDescriptor *td, const Catalog_Namespace::Catalog &cat)
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function: