OmniSciDB  04ee39c94c
UpdelStorageTest.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <csignal>
18 #include <cstdlib>
19 
20 #include <gtest/gtest.h>
21 
22 #include <boost/algorithm/string.hpp>
23 #include <boost/iterator/counting_iterator.hpp>
24 #include <boost/range/adaptor/transformed.hpp>
25 #include "boost/filesystem.hpp"
26 
27 #include "Catalog/Catalog.h"
29 #include "Import/Importer.h"
30 #include "Parser/parser.h"
31 #include "QueryEngine/ResultSet.h"
34 #include "Shared/MapDParameters.h"
35 #include "Shared/UpdelRoll.h"
36 #include "Shared/measure.h"
37 #include "TestHelpers.h"
38 
39 #ifndef BASE_PATH
40 #define BASE_PATH "./tmp"
41 #endif
42 
43 using namespace Catalog_Namespace;
44 
46 
47 namespace {
49  static bool showMeasuredTime;
52  static int64_t fixNumRows;
53  static int64_t varNumRows;
54  static std::string fixFile;
55  static std::string varFile;
56  static std::string sequence;
57 };
58 
59 constexpr static int varNumRowsByDefault = 8;
60 constexpr static int fixNumRowsByDefault = 100;
61 
62 bool UpdelTestConfig::showMeasuredTime = false;
63 bool UpdelTestConfig::enableVarUpdelPerfTest = false;
64 bool UpdelTestConfig::enableFixUpdelPerfTest = false;
65 int64_t UpdelTestConfig::fixNumRows = fixNumRowsByDefault;
66 int64_t UpdelTestConfig::varNumRows = varNumRowsByDefault;
67 std::string UpdelTestConfig::fixFile = "trip_data_b.txt";
68 std::string UpdelTestConfig::varFile = "varlen.txt";
69 std::string UpdelTestConfig::sequence = "rate_code_id";
70 } // namespace
71 
72 namespace {
73 struct ScalarTargetValueExtractor : public boost::static_visitor<std::string> {
74  result_type operator()(void*) const { return std::string("null"); }
75  result_type operator()(std::string const& rhs) const { return rhs; }
76  template <typename T>
77  result_type operator()(T const& rhs) const {
78  return std::to_string(rhs);
79  }
80  template <typename... VARIANT_ARGS>
81  result_type operator()(boost::variant<VARIANT_ARGS...> const& rhs) const {
82  return boost::apply_visitor(ScalarTargetValueExtractor(), rhs);
83  }
84 };
85 } // namespace
86 // namespace
87 namespace {
88 
89 inline void run_ddl_statement(const std::string& input_str) {
90  QR::get()->runDDLStatement(input_str);
91 }
92 
93 template <class T>
94 T v(const TargetValue& r) {
95  auto scalar_r = boost::get<ScalarTargetValue>(&r);
96  CHECK(scalar_r);
97  auto p = boost::get<T>(scalar_r);
98  CHECK(p);
99  return *p;
100 }
101 
102 std::shared_ptr<ResultSet> run_query(const std::string& query_str) {
103  return QR::get()->runSQL(query_str, ExecutorDeviceType::CPU, true, true);
104 }
105 
106 bool compare_agg(const std::string& table,
107  const std::string& column,
108  const int64_t cnt,
109  const double avg) {
110  std::string query_str = "SELECT COUNT(*), AVG(" + column + ") FROM " + table + ";";
111  auto rows = run_query(query_str);
112  auto crt_row = rows->getNextRow(true, true);
113  CHECK_EQ(size_t(2), crt_row.size());
114  auto r_cnt = v<int64_t>(crt_row[0]);
115  auto r_avg = v<double>(crt_row[1]);
116  // VLOG(1) << "r_avg: " << std::to_string(r_avg) << ", avg: " << std::to_string(avg);
117  return r_cnt == cnt && std::abs(r_avg - avg) < 1E-6;
118 }
119 
120 template <typename T>
121 void update_prepare_offsets_values(const int64_t cnt,
122  const int step,
123  const T val,
124  std::vector<uint64_t>& fragOffsets,
125  std::vector<ScalarTargetValue>& rhsValues) {
126  for (int64_t i = 0; i < cnt; i += step) {
127  fragOffsets.push_back(i);
128  }
129  rhsValues.push_back(ScalarTargetValue(val));
130 }
131 
132 template <typename T>
133 void update_common(const std::string& table,
134  const std::string& column,
135  const int64_t cnt,
136  const int step,
137  const T& val,
138  const SQLTypeInfo& rhsType,
139  const bool commit = true) {
140  UpdelRoll updelRoll;
141  std::vector<uint64_t> fragOffsets;
142  std::vector<ScalarTargetValue> rhsValues;
143  update_prepare_offsets_values<T>(cnt, step, val, fragOffsets, rhsValues);
145  QR::get()->getCatalog().get(),
146  table,
147  column,
148  0, // 1st frag since we have only 100 rows
149  fragOffsets,
150  rhsValues,
151  rhsType,
153  updelRoll);
154  if (commit) {
155  updelRoll.commitUpdate();
156  }
157 }
158 
159 bool update_a_numeric_column(const std::string& table,
160  const std::string& column,
161  const int64_t cnt,
162  const int step,
163  const double val,
164  const double avg,
165  const bool commit = true,
166  const bool by_string = false) {
167  if (by_string) {
168  update_common<std::string>(
169  table, column, cnt, step, std::to_string(val), SQLTypeInfo(), commit);
170  } else {
171  update_common<double>(table, column, cnt, step, val, SQLTypeInfo(), commit);
172  }
173  return compare_agg(table, column, cnt, avg);
174 }
175 
176 template <typename T>
177 bool nullize_a_fixed_encoded_column(const std::string& table,
178  const std::string& column,
179  const int64_t cnt) {
180  update_common<int64_t>(
181  table, column, cnt, 1, inline_int_null_value<T>(), SQLTypeInfo());
182  std::string query_str =
183  "SELECT count(*) FROM " + table + " WHERE " + column + " IS NULL;";
184  auto rows = run_query(query_str);
185  auto crt_row = rows->getNextRow(true, true);
186  CHECK_EQ(size_t(1), crt_row.size());
187  auto r_cnt = v<int64_t>(crt_row[0]);
188  return r_cnt == cnt;
189 }
190 
191 using ResultRow = std::vector<TargetValue>;
192 using ResultRows = std::vector<ResultRow>;
193 
194 const ResultRows get_some_rows(const std::string& table, const int limit = 10) {
195  ResultRows result_rows;
196  if (!UpdelTestConfig::enableVarUpdelPerfTest) {
197  std::string query_str =
198  "SELECT * FROM " + table + (limit ? " LIMIT " + std::to_string(limit) : "") + ";";
199  const auto rows = run_query(query_str);
200  // subtle here is we can't simply return ResultSet because it won't survive
201  // any rollback which wipes out all chunk data/metadata of the table, crashing
202  // UpdelRoll destructor that needs to free dirty chunks. So we need to copy
203  // the result rows out before the rollback ...
204  const auto nrow = rows->rowCount();
205  const auto ncol = rows->colCount();
206  for (std::remove_const<decltype(nrow)>::type r = 0; r < nrow; ++r) {
207  // translate string, or encoded strings won't be equal w/ boost ==
208  const auto row = rows->getNextRow(true, false);
209  std::vector<TargetValue> result_row;
210  for (std::remove_const<decltype(ncol)>::type c = 0; c < ncol; ++c) {
211  result_row.emplace_back(row[c]);
212  }
213  result_rows.emplace_back(result_row);
214  }
215  }
216  return result_rows;
217 }
218 
219 template <typename T>
220 TargetValue targetValue(std::true_type, const std::vector<T>& vals) {
221  return std::vector<ScalarTargetValue>(vals.begin(), vals.end());
222 }
223 
224 template <typename T>
225 TargetValue targetValue(std::false_type, const T& val) {
226  return ScalarTargetValue(val);
227 }
228 
229 const std::string dumpv(const TargetValue& tv) {
230  std::ostringstream os;
231  if (const auto svp = boost::get<ScalarTargetValue>(&tv)) {
232  os << *svp;
233  } else if (const auto avp = boost::get<ArrayTargetValue>(&tv)) {
234  const auto& svp = avp->get();
236  svp | boost::adaptors::transformed(ScalarTargetValueExtractor()), ",");
237  }
238  return os.str();
239 }
240 
241 inline bool is_equal(const TargetValue& lhs, const TargetValue& rhs) {
242  CHECK(!(boost::get<GeoTargetValue>(&lhs) || boost::get<GeoTargetValue>(&rhs)));
243  if (lhs.which() == rhs.which()) {
244  const auto l = boost::get<ScalarTargetValue>(&lhs);
245  const auto r = boost::get<ScalarTargetValue>(&rhs);
246  if (l && r) {
247  return *l == *r;
248  }
249  const auto la = boost::get<ArrayTargetValue>(&lhs);
250  const auto ra = boost::get<ArrayTargetValue>(&rhs);
251  if (la && ra) {
252  if (la->is_initialized() && ra->is_initialized()) {
253  const auto& lvec = la->get();
254  const auto& rvec = ra->get();
255  return lvec == rvec;
256  }
257  if (!la->is_initialized() && !ra->is_initialized()) {
258  // NULL arrays: consider them equal
259  return true;
260  }
261  }
262  }
263  return false;
264 }
265 
266 bool compare_row(const std::string& table,
267  const std::string& column,
268  const ResultRow& oldr,
269  const ResultRow& newr,
270  const TargetValue& val,
271  const bool commit) {
272  const auto cat = QR::get()->getCatalog();
273  const auto td = cat->getMetadataForTable(table);
274  const auto cdl = cat->getAllColumnMetadataForTable(td->tableId, false, false, false);
275  const auto cds = std::vector<const ColumnDescriptor*>(cdl.begin(), cdl.end());
276  const auto noldc = oldr.size();
277  const auto nnewc = newr.size();
278  const auto is_geophy_included = cds.size() < noldc;
279  CHECK_EQ(noldc, nnewc);
280  for (std::remove_const<decltype(noldc)>::type i = 0, c = 0; c < noldc;
281  c += is_geophy_included ? cds[i]->columnType.get_physical_cols() + 1 : 1, ++i) {
282  if (!is_equal(newr[c], (commit && cds[i]->columnName == column ? val : oldr[c]))) {
283  VLOG(1) << cds[i]->columnName << ": " << dumpv(newr[c]) << " - "
284  << dumpv((commit && cds[i]->columnName == column ? val : oldr[c]));
285  return false;
286  }
287  }
288  return true;
289 }
290 
291 bool update_a_encoded_string_column(const std::string& table,
292  const std::string& column,
293  const int64_t cnt,
294  const int step,
295  const std::string& val,
296  const bool commit = true) {
297  update_common<const std::string>(table, column, cnt, step, val, SQLTypeInfo(), commit);
298  // count updated string
299  std::string query_str =
300  "SELECT count(*) FROM " + table + " WHERE " + column + " = '" + val + "';";
301  auto rows = run_query(query_str);
302  auto crt_row = rows->getNextRow(true, true);
303  CHECK_EQ(size_t(1), crt_row.size());
304  auto r_cnt = v<int64_t>(crt_row[0]);
305  return r_cnt == (commit ? cnt / step : 0);
306 }
307 
308 #define update_a_datetime_column update_a_encoded_string_column
309 
310 bool update_a_boolean_column(const std::string& table,
311  const std::string& column,
312  const int64_t cnt,
313  const int step,
314  const bool val,
315  const bool commit = true) {
316  update_common<const std::string>(
317  table, column, cnt, step, val ? "T" : "F", SQLTypeInfo(), commit);
318  // count updated bools
319  std::string query_str =
320  "SELECT count(*) FROM " + table + " WHERE " + (val ? "" : " NOT ") + column + ";";
321  auto rows = run_query(query_str);
322  auto crt_row = rows->getNextRow(true, true);
323  CHECK_EQ(size_t(1), crt_row.size());
324  auto r_cnt = v<int64_t>(crt_row[0]);
325  return r_cnt == (commit ? cnt / step : 0);
326 }
327 
328 template <typename T>
329 bool update_column_from_decimal(const std::string& table,
330  const std::string& column,
331  const int64_t cnt,
332  const int64_t rhsDecimal,
333  const SQLTypeInfo& rhsType,
334  const SQLTypeInfo& lhsType,
335  const double max_loss,
336  const bool commit = true) {
337  update_common<int64_t>(table, column, cnt, 1, rhsDecimal, rhsType, commit);
338  std::string query_str = "SELECT DISTINCT " + column + " FROM " + table + ";";
339  auto rows = run_query(query_str);
340  CHECK_EQ(size_t(1), rows->rowCount());
341  auto crt_row = rows->getNextRow(true, false); // no decimal_to_double convert
342  auto l_decimal = v<T>(crt_row[0]);
343  int64_t r_decimal = rhsDecimal;
344 
345  if (lhsType.is_decimal()) {
346  l_decimal = convert_decimal_value_to_scale(l_decimal, lhsType, rhsType);
347  } else {
348  l_decimal *= pow(10, rhsType.get_scale());
349  }
350 
351  auto r_loss = std::abs(l_decimal - r_decimal) / r_decimal;
352  if (!(r_loss <= max_loss)) {
353  VLOG(1) << "l_decimal: " << l_decimal << ", r_decimal: " << r_decimal
354  << ", r_loss: " << r_loss << ", max_loss: " << max_loss;
355  }
356  return r_loss <= max_loss;
357 }
358 
359 void import_table_file(const std::string& table, const std::string& file) {
360  std::string query_str = std::string("COPY " + table + " FROM '") +
361  "../../Tests/Import/datafiles/" + file +
362  "' WITH (header='true');";
363 
364  SQLParser parser;
365  std::list<std::unique_ptr<Parser::Stmt>> parse_trees;
366  std::string last_parsed;
367  if (parser.parse(query_str, parse_trees, last_parsed)) {
368  throw std::runtime_error("Failed to parse: " + query_str);
369  }
370  CHECK_EQ(parse_trees.size(), size_t(1));
371 
372  const auto& stmt = parse_trees.front();
373  auto copy_stmt = dynamic_cast<Parser::CopyTableStmt*>(stmt.get());
374  if (!copy_stmt) {
375  throw std::runtime_error("Expected a CopyTableStatment: " + query_str);
376  }
377  QR::get()->runImport(copy_stmt);
378 }
379 
380 bool prepare_table_for_delete(const std::string& table = "trips",
381  const std::string& column = UpdelTestConfig::sequence,
382  const int64_t cnt = UpdelTestConfig::fixNumRows) {
383  UpdelRoll updelRoll;
384  std::vector<uint64_t> fragOffsets;
385  std::vector<ScalarTargetValue> rhsValues;
386  for (int64_t i = 0; i < cnt; ++i) {
387  fragOffsets.push_back(i);
388  rhsValues.emplace_back(ScalarTargetValue(i));
389  }
390  auto ms = measure<>::execution([&]() {
392  QR::get()->getCatalog().get(),
393  table,
394  column,
395  0, // 1st frag since we have only 100 rows
396  fragOffsets,
397  rhsValues,
398  SQLTypeInfo(kBIGINT, false),
400  updelRoll);
401  });
402  if (UpdelTestConfig::showMeasuredTime) {
403  VLOG(2) << "time on update " << cnt << " rows:" << ms << " ms";
404  }
405  ms = measure<>::execution([&]() { updelRoll.commitUpdate(); });
406  if (UpdelTestConfig::showMeasuredTime) {
407  VLOG(2) << "time on commit:" << ms << " ms";
408  }
409  return compare_agg(table, column, cnt, (0 + cnt - 1) * cnt / 2. / cnt);
410 }
411 
412 bool check_row_count_with_string(const std::string& table,
413  const std::string& column,
414  const int64_t cnt,
415  const std::string& val) {
416  std::string query_str =
417  "SELECT count(*) FROM " + table + " WHERE " + column + " = '" + val + "';";
418  auto rows = run_query(query_str);
419  auto crt_row = rows->getNextRow(true, true);
420  CHECK_EQ(size_t(1), crt_row.size());
421  auto r_cnt = v<int64_t>(crt_row[0]);
422  if (r_cnt == cnt) {
423  return true;
424  }
425  VLOG(1) << "r_cnt: " << std::to_string(r_cnt) << ", cnt: " << std::to_string(cnt);
426  return false;
427 }
428 
429 bool delete_and_immediately_vacuum_rows(const std::string& table,
430  const std::string& column,
431  const std::string& deleted_column,
432  const int64_t nall,
433  const int dcnt,
434  const int start,
435  const int step) {
436  // set a column to "traceable" values
437  if (false == prepare_table_for_delete(table, column, nall)) {
438  return false;
439  }
440 
441  // pre calc expected count and sum of the traceable values
442  UpdelRoll updelRoll;
443  std::vector<uint64_t> fragOffsets;
444  std::vector<ScalarTargetValue> rhsValues;
445  rhsValues.emplace_back(int64_t{1});
446  int64_t sum = 0, cnt = 0;
447  for (int d = 0, i = start; d < dcnt; ++d, i += step) {
448  fragOffsets.push_back(i);
449  sum += i;
450  cnt += 1;
451  }
452 
453  // delete and vacuum rows supposedly immediately
454  auto cat = QR::get()->getCatalog().get();
455  auto td = cat->getMetadataForTable(table);
456  auto cd = cat->getMetadataForColumn(td->tableId, deleted_column);
457  const_cast<ColumnDescriptor*>(cd)->isDeletedCol = true;
458  auto ms = measure<>::execution([&]() {
459  td->fragmenter->updateColumn(cat,
460  td,
461  cd,
462  0, // 1st frag since we have only 100 rows
463  fragOffsets,
464  rhsValues,
465  SQLTypeInfo(kBOOLEAN, false),
467  updelRoll);
468  });
469  if (UpdelTestConfig::showMeasuredTime) {
470  VLOG(2) << "time on delete & vacuum " << dcnt << " of " << nall << " rows:" << ms
471  << " ms";
472  }
473  ms = measure<>::execution([&]() { updelRoll.commitUpdate(); });
474  if (UpdelTestConfig::showMeasuredTime) {
475  VLOG(2) << "time on commit:" << ms << " ms";
476  }
477  cnt = nall - cnt;
478  // check varlen column vacuumed
479  if (false == check_row_count_with_string(
480  table, "hack_license", cnt, "BA96DE419E711691B9445D6A6307C170")) {
481  return false;
482  }
483  return compare_agg(
484  table, column, cnt, ((0 + nall - 1) * nall / 2. - sum) / (cnt ? cnt : 1));
485 }
486 
487 bool delete_and_vacuum_varlen_rows(const std::string& table,
488  const int nall,
489  const int ndel,
490  const int start,
491  const int step,
492  const bool manual_vacuum) {
493  const auto old_rows = get_some_rows(table, nall);
494 
495  std::vector<uint64_t> fragOffsets;
496  for (int d = 0, i = start; d < ndel && i < nall; ++d, i += step) {
497  fragOffsets.push_back(i);
498  }
499 
500  // delete and vacuum rows
501  auto cond = std::string("rowid >= ") + std::to_string(start) + " and mod(rowid-" +
502  std::to_string(start) + "," + std::to_string(step) + ")=0 and rowid < " +
503  std::to_string(start) + "+" + std::to_string(step) + "*" +
504  std::to_string(ndel);
505  auto ms = measure<>::execution([&]() {
506  ASSERT_NO_THROW(run_query("delete from " + table + " where " + cond + ";"););
507  });
508  if (UpdelTestConfig::showMeasuredTime) {
509  VLOG(2) << "time on delete " << (manual_vacuum ? "" : "& vacuum ")
510  << fragOffsets.size() << " rows:" << ms << " ms";
511  }
512 
513  if (manual_vacuum) {
514  ms = measure<>::execution([&]() {
515  auto cat = QR::get()->getCatalog().get();
516  const auto td = cat->getMetadataForTable(table,
517  /*populateFragmenter=*/true);
518  auto executor = Executor::getExecutor(cat->getCurrentDB().dbId);
519  TableOptimizer optimizer(td, executor.get(), *cat);
520  optimizer.vacuumDeletedRows();
521  optimizer.recomputeMetadata();
522  });
523  if (UpdelTestConfig::showMeasuredTime) {
524  VLOG(2) << "time on vacuum:" << ms << " ms";
525  }
526  }
527 
528  const auto new_rows = get_some_rows(table, nall);
529  if (!UpdelTestConfig::enableVarUpdelPerfTest) {
530  for (int oi = 0, ni = 0; oi < nall; ++oi) {
531  if (fragOffsets.end() == std::find(fragOffsets.begin(), fragOffsets.end(), oi)) {
532  if (!compare_row(table,
533  "",
534  old_rows[oi],
535  new_rows[ni++],
536  ScalarTargetValue(int64_t{1}),
537  false)) {
538  return false;
539  }
540  }
541  }
542  }
543  return true;
544 }
545 
546 // don't use R"()" format; somehow it causes many blank lines
547 // to be output on console. how come?
548 const std::string create_varlen_table1 =
549  "CREATE TABLE varlen("
550  "ti tinyint,"
551  "si smallint,"
552  "ii int,"
553  "bi bigint,"
554  "ff float,"
555  "fd double,"
556  "de decimal(5,2),"
557  "ts timestamp,"
558  "ns text encoding none,"
559  "es text encoding dict(16),"
560  // move these fixed array ahead of geo columns to bypass issue#2008
561  // for this unit test to continue independently :)
562  "faii int[2],"
563  "fadc decimal(5,2)[2],"
564  "fatx text[2],";
565 const std::string create_varlen_table2 =
566  "pt point,"
567  "ls linestring,"
568  "pg polygon,"
569  "mp multipolygon,";
570 const std::string create_varlen_table3 =
571  "ati tinyint[],"
572  "asi smallint[],"
573  "aii int[],"
574  "abi bigint[],"
575  "aff float[],"
576  "afd double[],"
577  "adc decimal(5,2)[],"
578  "atx text[],"
579  "ats timestamp[]"
580  ")";
581 
582 const std::string create_table_trips =
583  " CREATE TABLE trips ("
584  " medallion TEXT ENCODING DICT,"
585  " hack_license TEXT ENCODING DICT,"
586  " vendor_id TEXT ENCODING DICT,"
587  " rate_code_id SMALLINT ENCODING FIXED(8),"
588  " store_and_fwd_flag TEXT ENCODING DICT,"
589  " pickup_datetime TIMESTAMP,"
590  " dropoff_datetime TIMESTAMP,"
591  " passenger_count INTEGER ENCODING FIXED(16),"
592  " trip_time_in_secs INTEGER,"
593  " trip_distance FLOAT,"
594  " pickup_longitude DECIMAL(14,7),"
595  " pickup_latitude DECIMAL(14,7),"
596  " dropoff_longitude DOUBLE,"
597  " dropoff_latitude DECIMAL(18,5),"
598  " deleted BOOLEAN"
599  " )";
600 
601 void init_table_data(const std::string& table = "trips",
602  const std::string& create_table_cmd = create_table_trips,
603  const std::string& file = UpdelTestConfig::fixFile) {
604  run_ddl_statement("drop table if exists " + table + ";");
605  run_ddl_statement(create_table_cmd + ";");
606  if (file.size()) {
607  auto ms = measure<>::execution([&]() { import_table_file(table, file); });
608  if (UpdelTestConfig::showMeasuredTime) {
609  VLOG(2) << "time on import: " << ms << " ms";
610  }
611  }
612 }
613 
614 template <int N = 0>
615 class RowVacuumTestWithVarlenAndArraysN : public ::testing::Test {
616  protected:
617  void SetUp() override {
618  auto create_varlen_table =
619  create_varlen_table1 +
620  (UpdelTestConfig::enableVarUpdelPerfTest ? "" : create_varlen_table2) +
621  create_varlen_table3;
622  // test >1 fragments?
623  create_varlen_table +=
624  "WITH (FRAGMENT_SIZE = " + std::to_string(N ? N : 32'000'000) + ")";
625  ASSERT_NO_THROW(
626  init_table_data("varlen", create_varlen_table, UpdelTestConfig::varFile););
627  // immediate vacuum?
629  }
630 
631  void TearDown() override {
633  ASSERT_NO_THROW(run_ddl_statement("drop table varlen;"););
634  }
635 };
636 
638 TEST_F(RowVacuumTestWithVarlenAndArrays_0, Vacuum_Half_Then_Add_All) {
639  // delete and vacuum half of (8) rows
640  EXPECT_TRUE(delete_and_vacuum_varlen_rows("varlen",
641  UpdelTestConfig::varNumRows,
642  UpdelTestConfig::varNumRows / 2,
643  0,
644  1,
645  true));
646 
647  // add ALL row back
648  EXPECT_NO_THROW(import_table_file("varlen", UpdelTestConfig::varFile););
649  // check new added rows ...
650  auto rows = run_query("select ns from varlen where rowid >= " +
651  std::to_string(UpdelTestConfig::varNumRows / 2) + ";");
652  for (int i = 0; i < UpdelTestConfig::varNumRows; ++i) {
653  auto crt_row = rows->getNextRow(true, true);
654  CHECK_EQ(size_t(1), crt_row.size());
655  auto nullable_str = v<NullableString>(crt_row[0]);
656  auto ns = boost::get<std::string>(&nullable_str);
657  CHECK(ns);
658  EXPECT_TRUE(*ns == std::to_string(i + 1));
659  }
660 }
661 
665  EXPECT_TRUE(delete_and_vacuum_varlen_rows("varlen",
666  UpdelTestConfig::varNumRows,
667  UpdelTestConfig::varNumRows / 2,
668  0,
669  1,
670  true));
671 }
673  EXPECT_TRUE(delete_and_vacuum_varlen_rows("varlen",
674  UpdelTestConfig::varNumRows,
675  UpdelTestConfig::varNumRows / 2,
676  UpdelTestConfig::varNumRows / 2,
677  1,
678  true));
679 }
681  EXPECT_TRUE(delete_and_vacuum_varlen_rows("varlen",
682  UpdelTestConfig::varNumRows,
683  UpdelTestConfig::varNumRows / 2,
684  0,
685  2,
686  true));
687 }
689  EXPECT_TRUE(delete_and_vacuum_varlen_rows("varlen",
690  UpdelTestConfig::varNumRows,
691  UpdelTestConfig::varNumRows / 3,
692  0,
693  3,
694  true));
695 }
696 
697 // make class backward compatible
700  EXPECT_TRUE(delete_and_vacuum_varlen_rows("varlen",
701  UpdelTestConfig::varNumRows,
702  UpdelTestConfig::varNumRows / 2,
703  0,
704  1,
705  false));
706 }
708  EXPECT_TRUE(delete_and_vacuum_varlen_rows("varlen",
709  UpdelTestConfig::varNumRows,
710  UpdelTestConfig::varNumRows / 2,
711  UpdelTestConfig::varNumRows / 2,
712  1,
713  false));
714 }
715 TEST_F(RowVacuumTestWithVarlenAndArrays, Vacuum_Interleaved_2) {
716  EXPECT_TRUE(delete_and_vacuum_varlen_rows("varlen",
717  UpdelTestConfig::varNumRows,
718  UpdelTestConfig::varNumRows / 2,
719  0,
720  2,
721  false));
722 }
723 TEST_F(RowVacuumTestWithVarlenAndArrays, Vacuum_Interleaved_3) {
724  EXPECT_TRUE(delete_and_vacuum_varlen_rows("varlen",
725  UpdelTestConfig::varNumRows,
726  UpdelTestConfig::varNumRows / 3,
727  0,
728  3,
729  false));
730 }
731 
732 class RowVacuumTest : public ::testing::Test {
733  protected:
734  void SetUp() override {
735  ASSERT_NO_THROW(init_table_data(););
737  }
738 
739  void TearDown() override {
741  ASSERT_NO_THROW(run_ddl_statement("drop table trips;"););
742  }
743 };
744 
745 TEST_F(RowVacuumTest, Vacuum_Half_First) {
746  EXPECT_TRUE(delete_and_immediately_vacuum_rows("trips",
747  UpdelTestConfig::sequence,
748  "deleted",
749  UpdelTestConfig::fixNumRows,
750  UpdelTestConfig::fixNumRows / 2,
751  0,
752  1));
753 }
754 TEST_F(RowVacuumTest, Vacuum_Half_Second) {
755  EXPECT_TRUE(delete_and_immediately_vacuum_rows("trips",
756  UpdelTestConfig::sequence,
757  "deleted",
758  UpdelTestConfig::fixNumRows,
759  UpdelTestConfig::fixNumRows / 2,
760  UpdelTestConfig::fixNumRows / 2,
761  1));
762 }
763 TEST_F(RowVacuumTest, Vacuum_Interleaved_2) {
764  EXPECT_TRUE(delete_and_immediately_vacuum_rows("trips",
765  UpdelTestConfig::sequence,
766  "deleted",
767  UpdelTestConfig::fixNumRows,
768  UpdelTestConfig::fixNumRows / 2,
769  0,
770  2));
771 }
772 TEST_F(RowVacuumTest, Vacuum_Interleaved_4) {
773  EXPECT_TRUE(delete_and_immediately_vacuum_rows("trips",
774  UpdelTestConfig::sequence,
775  "deleted",
776  UpdelTestConfig::fixNumRows,
777  UpdelTestConfig::fixNumRows / 4,
778  0,
779  4));
780 }
781 
782 // It is currently not possible to do select query on temp table w/o
783 // MapDHandler. Perhaps in the future a thrift rpc like `push_table_details`
784 // can be added to enable such queries here...
785 #if 0
786 const char* create_temp_table = "CREATE TEMPORARY TABLE temp(i int) WITH (vacuum='delayed');";
787 
788 class UpdateStorageTest_Temp : public ::testing::Test {
789  protected:
790  virtual void SetUp() {
791  ASSERT_NO_THROW(init_table_data("temp", create_temp_table, ""););
792  EXPECT_NO_THROW(run_query("insert into temp values(1)"););
793  EXPECT_NO_THROW(run_query("insert into temp values(1)"););
794  }
795 
796  virtual void TearDown() { ASSERT_NO_THROW(run_ddl_statement("drop table temp;");); }
797 };
798 
799 TEST_F(UpdateStorageTest_Temp, Update_temp) {
800  EXPECT_TRUE(update_a_numeric_column("temp", "i", 2, 1, 99, 99));
801 }
802 
803 TEST_F(UpdateStorageTest_Temp, Update_temp_rollback) {
804  EXPECT_TRUE(update_a_numeric_column("temp", "i", 2, 1, 99, 1, true));
805 }
806 #endif
807 
808 class UpdateStorageTest : public ::testing::Test {
809  protected:
810  void SetUp() override { ASSERT_NO_THROW(init_table_data();); }
811 
812  void TearDown() override { ASSERT_NO_THROW(run_ddl_statement("drop table trips;");); }
813 };
814 
815 TEST_F(UpdateStorageTest, All_fixed_encoded_smallint_rate_code_id_null_8) {
816  EXPECT_TRUE(nullize_a_fixed_encoded_column<int8_t>(
817  "trips", "rate_code_id", UpdelTestConfig::fixNumRows));
818 }
819 TEST_F(UpdateStorageTest, All_fixed_encoded_smallint_rate_code_id_null_16) {
820  EXPECT_TRUE(nullize_a_fixed_encoded_column<int16_t>(
821  "trips", "rate_code_id", UpdelTestConfig::fixNumRows));
822 }
823 TEST_F(UpdateStorageTest, All_fixed_encoded_smallint_rate_code_id_null_32_throw) {
824  EXPECT_THROW(nullize_a_fixed_encoded_column<int32_t>(
825  "trips", "rate_code_id", UpdelTestConfig::fixNumRows),
826  std::runtime_error);
827 }
828 TEST_F(UpdateStorageTest, All_fixed_encoded_smallint_rate_code_id_null_64_throw) {
829  EXPECT_THROW(nullize_a_fixed_encoded_column<int64_t>(
830  "trips", "rate_code_id", UpdelTestConfig::fixNumRows),
831  std::runtime_error);
832 }
833 
834 TEST_F(UpdateStorageTest, All_fixed_encoded_integer_passenger_count_null_16) {
835  EXPECT_TRUE(nullize_a_fixed_encoded_column<int16_t>(
836  "trips", "passenger_count", UpdelTestConfig::fixNumRows));
837 }
838 TEST_F(UpdateStorageTest, All_fixed_encoded_integer_passenger_count_null_32) {
839  EXPECT_TRUE(nullize_a_fixed_encoded_column<int32_t>(
840  "trips", "passenger_count", UpdelTestConfig::fixNumRows));
841 }
842 TEST_F(UpdateStorageTest, All_fixed_encoded_integer_passenger_count_null_64_throw) {
843  EXPECT_THROW(nullize_a_fixed_encoded_column<int64_t>(
844  "trips", "passenger_count", UpdelTestConfig::fixNumRows),
845  std::runtime_error);
846 }
847 
848 TEST_F(UpdateStorageTest, All_integer_trip_time_in_secs_null_32) {
849  EXPECT_TRUE(nullize_a_fixed_encoded_column<int32_t>(
850  "trips", "trip_time_in_secs", UpdelTestConfig::fixNumRows));
851 }
852 TEST_F(UpdateStorageTest, All_integer_trip_time_in_secs_null_64_throw) {
853  EXPECT_THROW(nullize_a_fixed_encoded_column<int64_t>(
854  "trips", "trip_time_in_secs", UpdelTestConfig::fixNumRows),
855  std::runtime_error);
856 }
857 
858 TEST_F(UpdateStorageTest, All_fixed_encoded_smallint_rate_code_id_throw) {
859  EXPECT_TRUE(update_a_numeric_column(
860  "trips", "rate_code_id", UpdelTestConfig::fixNumRows, 1, 44 * 2, 44 * 2.0));
861  EXPECT_THROW(update_a_numeric_column(
862  "trips", "rate_code_id", UpdelTestConfig::fixNumRows, 1, +257, +257),
863  std::runtime_error);
864  EXPECT_THROW(update_a_numeric_column(
865  "trips", "rate_code_id", UpdelTestConfig::fixNumRows, 1, -256, -256),
866  std::runtime_error);
867 }
868 
869 #define SQLTypeInfo_dropoff_latitude SQLTypeInfo(kDECIMAL, 19, 5, false)
870 TEST_F(UpdateStorageTest, All_RHS_decimal_10_0_LHS_decimal_19_5) {
871  EXPECT_TRUE(update_column_from_decimal<int64_t>("trips",
872  "dropoff_latitude",
873  UpdelTestConfig::fixNumRows,
874  1234506789,
875  SQLTypeInfo(kDECIMAL, 10, 0, false),
877  0));
878 }
879 TEST_F(UpdateStorageTest, All_RHS_decimal_10_2_LHS_decimal_19_5) {
880  EXPECT_TRUE(update_column_from_decimal<int64_t>("trips",
881  "dropoff_latitude",
882  UpdelTestConfig::fixNumRows,
883  1234506789,
884  SQLTypeInfo(kDECIMAL, 10, 2, false),
886  0));
887 }
888 TEST_F(UpdateStorageTest, All_RHS_decimal_15_2_LHS_decimal_19_5) {
889  EXPECT_TRUE(update_column_from_decimal<int64_t>("trips",
890  "dropoff_latitude",
891  UpdelTestConfig::fixNumRows,
892  123456789012345,
893  SQLTypeInfo(kDECIMAL, 15, 2, false),
895  0));
896 }
897 TEST_F(UpdateStorageTest, All_RHS_decimal_17_2_LHS_decimal_19_5_throw) {
898  EXPECT_THROW(update_column_from_decimal<int64_t>("trips",
899  "dropoff_latitude",
900  UpdelTestConfig::fixNumRows,
901  12345678901234567,
902  SQLTypeInfo(kDECIMAL, 17, 2, false),
904  0),
905  std::runtime_error);
906 }
907 
908 #define SQLTypeInfo_dropoff_longitude SQLTypeInfo(kDOUBLE, false)
909 TEST_F(UpdateStorageTest, All_RHS_decimal_10_0_LHS_double) {
910  EXPECT_TRUE(update_column_from_decimal<double>("trips",
911  "dropoff_longitude",
912  UpdelTestConfig::fixNumRows,
913  1234506789,
914  SQLTypeInfo(kDECIMAL, 10, 0, false),
916  1E-15));
917 }
918 TEST_F(UpdateStorageTest, All_RHS_decimal_10_2_LHS_double) {
919  EXPECT_TRUE(update_column_from_decimal<double>("trips",
920  "dropoff_longitude",
921  UpdelTestConfig::fixNumRows,
922  1234506789,
923  SQLTypeInfo(kDECIMAL, 10, 2, false),
925  1E-15));
926 }
927 TEST_F(UpdateStorageTest, All_RHS_decimal_15_2_LHS_double) {
928  EXPECT_TRUE(update_column_from_decimal<double>("trips",
929  "dropoff_longitude",
930  UpdelTestConfig::fixNumRows,
931  123456789012345,
932  SQLTypeInfo(kDECIMAL, 15, 2, false),
934  1E-15));
935 }
936 
937 #define SQLTypeInfo_trip_time_in_secs SQLTypeInfo(kINT, false)
938 TEST_F(UpdateStorageTest, All_RHS_decimal_10_0_LHS_integer) {
939  EXPECT_TRUE(update_column_from_decimal<int64_t>("trips",
940  "trip_time_in_secs",
941  UpdelTestConfig::fixNumRows,
942  1234506789,
943  SQLTypeInfo(kDECIMAL, 10, 0, false),
945  1));
946 }
947 TEST_F(UpdateStorageTest, All_RHS_decimal_10_2_LHS_integer) {
948  EXPECT_TRUE(update_column_from_decimal<int64_t>("trips",
949  "trip_time_in_secs",
950  UpdelTestConfig::fixNumRows,
951  1234506789,
952  SQLTypeInfo(kDECIMAL, 10, 2, false),
954  1));
955 }
956 TEST_F(UpdateStorageTest, All_RHS_decimal_15_5_LHS_integer) {
957  EXPECT_TRUE(update_column_from_decimal<int64_t>("trips",
958  "trip_time_in_secs",
959  UpdelTestConfig::fixNumRows,
960  123456789012345,
961  SQLTypeInfo(kDECIMAL, 15, 5, false),
963  1));
964 }
965 
966 TEST_F(UpdateStorageTest, All_fixed_encoded_integer_passenger_count_x1_throw) {
967  EXPECT_TRUE(update_a_numeric_column(
968  "trips", "passenger_count", UpdelTestConfig::fixNumRows, 1, 4 * 2, 4 * 2.0));
969  EXPECT_THROW(
971  "trips", "passenger_count", UpdelTestConfig::fixNumRows, 1, +65537, +65537),
972  std::runtime_error);
973  EXPECT_THROW(
975  "trips", "passenger_count", UpdelTestConfig::fixNumRows, 1, -65536, -65536),
976  std::runtime_error);
977 }
978 TEST_F(UpdateStorageTest, All_fixed_encoded_integer_passenger_count_x1_rollback) {
979  EXPECT_TRUE(update_a_numeric_column(
980  "trips", "passenger_count", UpdelTestConfig::fixNumRows, 1, 4 * 2, 4 * 1.0, false));
981 }
982 
983 TEST_F(UpdateStorageTest, Half_fixed_encoded_integer_passenger_count_x2) {
984  EXPECT_TRUE(update_a_numeric_column(
985  "trips", "passenger_count", UpdelTestConfig::fixNumRows, 2, 4 * 2, 4. * 1.5));
986 }
987 TEST_F(UpdateStorageTest, Half_fixed_encoded_integer_passenger_count_x2_rollback) {
988  EXPECT_TRUE(update_a_numeric_column("trips",
989  "passenger_count",
990  UpdelTestConfig::fixNumRows,
991  2,
992  4 * 2,
993  4. * 1.0,
994  false));
995 }
996 
997 TEST_F(UpdateStorageTest, All_int_trip_time_in_secs_x2) {
998  EXPECT_TRUE(update_a_numeric_column(
999  "trips", "trip_time_in_secs", UpdelTestConfig::fixNumRows, 1, 382 * 2, 382 * 2.0));
1000 }
1001 TEST_F(UpdateStorageTest, All_int_trip_time_in_secs_x2_rollback) {
1002  EXPECT_TRUE(update_a_numeric_column("trips",
1003  "trip_time_in_secs",
1004  UpdelTestConfig::fixNumRows,
1005  1,
1006  382 * 2,
1007  382 * 1.0,
1008  false));
1009 }
1010 
1011 TEST_F(UpdateStorageTest, Half_int_trip_time_in_secs_x2) {
1012  EXPECT_TRUE(update_a_numeric_column(
1013  "trips", "trip_time_in_secs", UpdelTestConfig::fixNumRows, 2, 382 * 2, 382. * 1.5));
1014 }
1015 TEST_F(UpdateStorageTest, Half_int_trip_time_in_secs_x2_rollback) {
1016  EXPECT_TRUE(update_a_numeric_column("trips",
1017  "trip_time_in_secs",
1018  UpdelTestConfig::fixNumRows,
1019  2,
1020  382 * 2,
1021  382. * 1.0,
1022  false));
1023 }
1024 
1025 TEST_F(UpdateStorageTest, All_float_trip_distance_x2) {
1026  EXPECT_TRUE(update_a_numeric_column(
1027  "trips", "trip_distance", UpdelTestConfig::fixNumRows, 1, 1 * 2, 1 * 2.0));
1028 }
1029 TEST_F(UpdateStorageTest, All_float_trip_distance_x2_rollback) {
1030  EXPECT_TRUE(update_a_numeric_column(
1031  "trips", "trip_distance", UpdelTestConfig::fixNumRows, 1, 1 * 2, 1 * 1.0, false));
1032 }
1033 
1034 TEST_F(UpdateStorageTest, Half_float_trip_distance_x2) {
1035  EXPECT_TRUE(update_a_numeric_column(
1036  "trips", "trip_distance", UpdelTestConfig::fixNumRows, 2, 1 * 2, 1. * 1.5));
1037 }
1038 TEST_F(UpdateStorageTest, Half_float_trip_distance_x2_rollback) {
1039  EXPECT_TRUE(update_a_numeric_column(
1040  "trips", "trip_distance", UpdelTestConfig::fixNumRows, 2, 1 * 2, 1. * 1.0, false));
1041 }
1042 
1043 TEST_F(UpdateStorageTest, All_string_vendor_id) {
1044  EXPECT_TRUE(update_a_encoded_string_column(
1045  "trips", "vendor_id", UpdelTestConfig::fixNumRows, 1, "abcxyz"));
1046 }
1047 TEST_F(UpdateStorageTest, All_string_vendor_id_rollback) {
1048  EXPECT_TRUE(update_a_encoded_string_column(
1049  "trips", "vendor_id", UpdelTestConfig::fixNumRows, 1, "abcxyz", false));
1050 }
1051 
1052 TEST_F(UpdateStorageTest, Half_string_vendor_id) {
1053  EXPECT_TRUE(update_a_encoded_string_column(
1054  "trips", "vendor_id", UpdelTestConfig::fixNumRows, 2, "xyzabc"));
1055 }
1056 TEST_F(UpdateStorageTest, Half_string_vendor_id_rollback) {
1057  EXPECT_TRUE(update_a_encoded_string_column(
1058  "trips", "vendor_id", UpdelTestConfig::fixNumRows, 2, "xyzabc", false));
1059 }
1060 
1061 TEST_F(UpdateStorageTest, All_boolean_deleted) {
1062  EXPECT_TRUE(
1063  update_a_boolean_column("trips", "deleted", UpdelTestConfig::fixNumRows, 1, true));
1064 }
1065 TEST_F(UpdateStorageTest, All_boolean_deleted_rollback) {
1066  EXPECT_TRUE(update_a_boolean_column(
1067  "trips", "deleted", UpdelTestConfig::fixNumRows, 1, true, false));
1068 }
1069 
1070 TEST_F(UpdateStorageTest, Half_boolean_deleted) {
1071  EXPECT_TRUE(
1072  update_a_boolean_column("trips", "deleted", UpdelTestConfig::fixNumRows, 2, true));
1073 }
1074 TEST_F(UpdateStorageTest, Half_boolean_deleted_rollback) {
1075  EXPECT_TRUE(update_a_boolean_column(
1076  "trips", "deleted", UpdelTestConfig::fixNumRows, 2, true, false));
1077 }
1078 
1079 } // namespace
1080 
1081 int main(int argc, char** argv) {
1083  testing::InitGoogleTest(&argc, argv);
1084 
1086 
1087  // the data files for perf tests are too big to check in, so perf tests
1088  // are done privately in someone's dev host. prog option seems a overkill.
1089  auto var_file = getenv("updel_var_file"); // used to be "varlen.big"
1090  auto var_nrow = getenv("updel_var_nrow"); // used to be 1'000'000
1091  auto fix_file = getenv("updel_fix_file"); // used to be S3 file "trip_data_32m.tgz"
1092  auto fix_nrow = getenv("updel_fix_nrow"); // used to be 32'000'000
1093  if (var_file && *var_file && var_nrow && *var_nrow) {
1094  UpdelTestConfig::enableVarUpdelPerfTest = true;
1095  UpdelTestConfig::varFile = var_file;
1096  UpdelTestConfig::varNumRows = atoi(var_nrow);
1097  }
1098  if (fix_file && *fix_file && fix_nrow && *fix_nrow) {
1099  UpdelTestConfig::enableFixUpdelPerfTest = true;
1100  UpdelTestConfig::fixFile = fix_file;
1101  UpdelTestConfig::fixNumRows = atoi(fix_nrow);
1102  }
1103  UpdelTestConfig::showMeasuredTime =
1104  UpdelTestConfig::enableVarUpdelPerfTest || UpdelTestConfig::enableFixUpdelPerfTest;
1105 
1106  int err{0};
1107  try {
1108  err = RUN_ALL_TESTS();
1109  } catch (const std::exception& e) {
1110  LOG(ERROR) << e.what();
1111  }
1112  QR::reset();
1113  return err;
1114 }
static void setUnconditionalVacuum(const double unconditionalVacuum)
Definition: Fragmenter.h:118
#define BASE_PATH
#define CHECK_EQ(x, y)
Definition: Logger.h:195
bool prepare_table_for_delete(const std::string &table="trips", const std::string &column=UpdelTestConfig::sequence, const int64_t cnt=UpdelTestConfig::fixNumRows)
void d(const SQLTypes expected_type, const std::string &str)
Definition: ImportTest.cpp:268
static std::shared_ptr< Executor > getExecutor(const int db_id, const std::string &debug_dir="", const std::string &debug_file="", const MapDParameters mapd_parameters=MapDParameters(), ::QueryRenderer::QueryRenderManager *render_manager=nullptr)
Definition: Execute.cpp:122
#define SQLTypeInfo_dropoff_latitude
void commitUpdate()
result_type operator()(boost::variant< VARIANT_ARGS... > const &rhs) const
std::shared_ptr< ResultSet > run_query(const std::string &query_str)
bool update_a_boolean_column(const std::string &table, const std::string &column, const int64_t cnt, const int step, const bool val, const bool commit=true)
bool update_a_encoded_string_column(const std::string &table, const std::string &column, const int64_t cnt, const int step, const std::string &val, const bool commit=true)
#define LOG(tag)
Definition: Logger.h:182
const ResultRows get_some_rows(const std::string &table, const int limit=10)
void c(const std::string &query_string, const ExecutorDeviceType device_type)
std::string join(T const &container, std::string const &delim)
Driver for running cleanup processes on a table. TableOptimizer provides functions for various cleanu...
bool delete_and_immediately_vacuum_rows(const std::string &table, const std::string &column, const std::string &deleted_column, const int64_t nall, const int dcnt, const int start, const int step)
std::string to_string(char const *&&v)
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
virtual std::shared_ptr< ResultSet > runSQL(const std::string &query_str, const ExecutorDeviceType device_type, const bool hoist_literals=true, const bool allow_loop_joins=true)
This file contains the class specification and related data structures for Catalog.
T v(const TargetValue &r)
const std::string dumpv(const TargetValue &tv)
bool is_decimal() const
Definition: sqltypes.h:453
virtual void runImport(Parser::CopyTableStmt *import_stmt)
bool check_row_count_with_string(const std::string &table, const std::string &column, const int64_t cnt, const std::string &val)
virtual void runDDLStatement(const std::string &)
specifies the content in-memory of a row in the column metadata table
SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities > SQLTypeInfo
Definition: sqltypes.h:823
int main(int argc, char **argv)
TargetValue targetValue(std::false_type, const T &val)
std::shared_ptr< Catalog_Namespace::Catalog > getCatalog() const
void import_table_file(const std::string &table, const std::string &file)
void update_common(const std::string &table, const std::string &column, const int64_t cnt, const int step, const T &val, const SQLTypeInfo &rhsType, const bool commit=true)
static QueryRunner * get()
Definition: QueryRunner.h:115
bool compare_agg(const std::string &table, const std::string &column, const int64_t cnt, const double avg)
void vacuumDeletedRows() const
Compacts fragments to remove deleted rows. When a row is deleted, a boolean deleted system column is ...
bool update_a_numeric_column(const std::string &table, const std::string &column, const int64_t cnt, const int step, const double val, const double avg, const bool commit=true, const bool by_string=false)
#define SQLTypeInfo_dropoff_longitude
void update_prepare_offsets_values(const int64_t cnt, const int step, const T val, std::vector< uint64_t > &fragOffsets, std::vector< ScalarTargetValue > &rhsValues)
int64_t convert_decimal_value_to_scale(const int64_t decimal_value, const SQLTypeInfo &type_info, const SQLTypeInfo &new_type_info)
Definition: Datum.cpp:284
bool update_column_from_decimal(const std::string &table, const std::string &column, const int64_t cnt, const int64_t rhsDecimal, const SQLTypeInfo &rhsType, const SQLTypeInfo &lhsType, const double max_loss, const bool commit=true)
bool compare_row(const std::string &table, const std::string &column, const ResultRow &oldr, const ResultRow &newr, const TargetValue &val, const bool commit)
TEST_F(UpdateStorageTest, Half_boolean_deleted_rollback)
static void updateColumn(const Catalog_Namespace::Catalog *catalog, const std::string &tab_name, const std::string &col_name, const int fragment_id, const std::vector< uint64_t > &frag_offsets, const std::vector< ScalarTargetValue > &rhs_values, const SQLTypeInfo &rhs_type, const Data_Namespace::MemoryLevel memory_level, UpdelRoll &updel_roll)
#define SQLTypeInfo_trip_time_in_secs
#define CHECK(condition)
Definition: Logger.h:187
void init_logger_stderr_only(int argc, char const *const *argv)
Definition: TestHelpers.h:194
static TimeT::rep execution(F func, Args &&... args)
Definition: sample.cpp:29
Basic constructors and methods of the row set interface.
boost::variant< ScalarTargetValue, ArrayTargetValue, GeoTargetValue, GeoTargetValuePtr > TargetValue
Definition: TargetValue.h:167
bool is_equal(const TargetValue &lhs, const TargetValue &rhs)
bool delete_and_vacuum_varlen_rows(const std::string &table, const int nall, const int ndel, const int start, const int step, const bool manual_vacuum)
void init_table_data(const std::string &table="trips", const std::string &create_table_cmd=create_table_trips, const std::string &file=UpdelTestConfig::fixFile)
bool nullize_a_fixed_encoded_column(const std::string &table, const std::string &column, const int64_t cnt)
void run_ddl_statement(std::string ddl)
#define VLOG(n)
Definition: Logger.h:277
boost::variant< int64_t, double, float, NullableString > ScalarTargetValue
Definition: TargetValue.h:156