OmniSciDB  04ee39c94c
UpdateMetadataTest.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 <boost/program_options.hpp>
+ Include dependency graph for UpdateMetadataTest.cpp:

Go to the source code of this file.

Classes

class  MetadataUpdate< NSHARDS >
 
class  anonymous_namespace{UpdateMetadataTest.cpp}::TableCycler
 

Namespaces

 

Macros

#define BASE_PATH   "./tmp"
 

Typedefs

using QR = QueryRunner::QueryRunner
 

Functions

void anonymous_namespace{UpdateMetadataTest.cpp}::run_ddl_statement (const std::string &create_table_stmt)
 
std::shared_ptr< ResultSetanonymous_namespace{UpdateMetadataTest.cpp}::run_multiple_agg (const std::string &query_str, const ExecutorDeviceType device_type)
 
auto anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler (char const *table_name, char const *column_type)
 
 TEST_F (MetadataUpdate, MetadataTimestampNull)
 
 TEST_F (MetadataUpdate, MetadataTimestampNotNull)
 
 TEST_F (MetadataUpdate, MetadataTimeNull)
 
 TEST_F (MetadataUpdate, MetadataTimeNotNull)
 
 TEST_F (MetadataUpdate, MetadataDateNull)
 
 TEST_F (MetadataUpdate, MetadataDecimalNull)
 
 TEST_F (MetadataUpdate, MetadataDecimalNotNull)
 
 TEST_F (MetadataUpdate, MetadataIntegerNull)
 
 TEST_F (MetadataUpdate, IntegerNotNull)
 
 TEST_F (MetadataUpdate, MetadataTinyIntNull)
 
 TEST_F (MetadataUpdate, MetadataTinyIntNotNull)
 
 TEST_F (MetadataUpdate, MetadataAddColumnWithDeletes)
 
 TEST_F (MetadataUpdate, MetadataSmallIntNull)
 
 TEST_F (MetadataUpdate, MetadataSmallIntNotNull)
 
 TEST_F (MetadataUpdate, MetadataBigIntNull)
 
 TEST_F (MetadataUpdate, MetadataBigIntNotNull)
 
 TEST_F (MetadataUpdate, MetadataBooleanNull)
 
 TEST_F (MetadataUpdate, MetadataBooleanNotNull)
 
 TEST_F (MetadataUpdate, MetadataFloatNull)
 
 TEST_F (MetadataUpdate, MetadataFloatNotNull)
 
 TEST_F (MetadataUpdate, MetadataDoubleNull)
 
 TEST_F (MetadataUpdate, MetadataDoubleNotNull)
 
 TEST_F (MetadataUpdate, MetadataStringDict8Null)
 
 TEST_F (MetadataUpdate, MetadataStringDict16Null)
 
 TEST_F (MetadataUpdate, MetadataStringDict32Null)
 
 TEST_F (MetadataUpdate, MetadataSmallIntEncodedNull)
 
 TEST_F (MetadataUpdate, MetadataSmallIntEncodedNotNull)
 
int main (int argc, char **argv)
 

Variables

bool anonymous_namespace{UpdateMetadataTest.cpp}::g_keep_test_data {false}
 
auto anonymous_namespace{UpdateMetadataTest.cpp}::query
 
auto anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec
 

Macro Definition Documentation

◆ BASE_PATH

#define BASE_PATH   "./tmp"

Definition at line 30 of file UpdateMetadataTest.cpp.

Referenced by main().

Typedef Documentation

◆ QR

Definition at line 34 of file UpdateMetadataTest.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 1536 of file UpdateMetadataTest.cpp.

References BASE_PATH, logger::ERROR, anonymous_namespace{UpdateMetadataTest.cpp}::g_keep_test_data, logger::LogOptions::get_options(), QueryRunner::QueryRunner::init(), logger::init(), LOG, logger::LogOptions::max_files_, QueryRunner::QueryRunner::reset(), and run.

1536  {
1537  testing::InitGoogleTest(&argc, argv);
1538  namespace po = boost::program_options;
1539 
1540  po::options_description desc("Options");
1541  desc.add_options()("keep-data", "Don't drop tables at the end of the tests");
1542 
1543  logger::LogOptions log_options(argv[0]);
1544  log_options.max_files_ = 0; // stderr only by default
1545  desc.add(log_options.get_options());
1546 
1547  po::variables_map vm;
1548  po::store(po::command_line_parser(argc, argv).options(desc).run(), vm);
1549  po::notify(vm);
1550 
1551  logger::init(log_options);
1552 
1553  if (vm.count("keep-data")) {
1554  g_keep_test_data = true;
1555  }
1556 
1558 
1559  int err{0};
1560  try {
1561  err = RUN_ALL_TESTS();
1562  } catch (const std::exception& e) {
1563  LOG(ERROR) << e.what();
1564  }
1565  QR::reset();
1566  return err;
1567 }
#define BASE_PATH
#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
void init(LogOptions const &log_opts)
Definition: Logger.cpp:260
static bool run
+ Here is the call graph for this function:

◆ TEST_F() [1/27]

TEST_F ( MetadataUpdate  ,
MetadataTimestampNull   
)

Definition at line 128 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

128  {
129  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
130  return;
131  }
132 
133  // For timestamp column x:
134  // 1 - Check that the MIN metadata value is unperturbed
135  // 2 - Check that the presence of null is properly signaled
136  make_table_cycler("timestamp_null_table", "timestamp")([&] {
137  query("insert into timestamp_null_table values ('1946-06-14 10:54:00');");
138  query("insert into timestamp_null_table values ('2017-01-20 12:00:00');");
139 
140  auto pre_metadata = get_metadata_vec("timestamp_null_table");
141  ASSERT_EQ(pre_metadata.size(), 1U);
142  auto pre_metadata_chunk = pre_metadata[0].second;
143 
144  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
145  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
146 
147  query("update timestamp_null_table set x = NULL where x < '2000-01-01 00:00:00';");
148 
149  auto post_metadata = get_metadata_vec("timestamp_null_table");
150  ASSERT_EQ(post_metadata.size(), 1U);
151  auto post_metadata_chunk = post_metadata[0].second;
152 
153  // Check that a null update doesn't change the before and after min-max
154  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.bigintval,
155  post_metadata_chunk.chunkStats.min.bigintval);
156  ASSERT_EQ(post_metadata_chunk.chunkStats.max.bigintval,
157  post_metadata_chunk.chunkStats.max.bigintval);
158  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
159 
160  query("update timestamp_null_table set x='1000-01-01 00:00:00' where x is NULL;");
161  post_metadata = get_metadata_vec("timestamp_null_table");
162  ASSERT_EQ(post_metadata.size(), 1U);
163  post_metadata_chunk = post_metadata[0].second;
164 
165  // At this point, we prove that -INT_MIN is not set because
166  // of a null update, and that the min is constrained to
167  // the integer value corresponding to the minimum timestamp
168  //
169  // Addendum: There is no range checking on timestamps, however.
170  auto timestamp_minval = post_metadata_chunk.chunkStats.min.bigintval;
171  ASSERT_EQ(timestamp_minval, -30610224000);
172  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
173 
174  // Set the max, then verify that the min/max are the max possible for timestamp ranges
175  // and also verify that the has null is still true
176  query(
177  "update timestamp_null_table set x='12/31/2900 23:59:59.999' where x='1000-01-01 "
178  "00:00:00';");
179  post_metadata = get_metadata_vec("timestamp_null_table");
180  ASSERT_EQ(post_metadata.size(), 1U);
181  post_metadata_chunk = post_metadata[0].second;
182 
183  ASSERT_EQ(post_metadata_chunk.chunkStats.max.bigintval, 29379542399);
184  ASSERT_EQ(post_metadata_chunk.chunkStats.min.bigintval, -30610224000);
185  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
186  ASSERT_GT(post_metadata_chunk.chunkStats.max.bigintval,
187  pre_metadata_chunk.chunkStats.max.bigintval);
188  ASSERT_LT(post_metadata_chunk.chunkStats.min.bigintval,
189  pre_metadata_chunk.chunkStats.min.bigintval);
190  });
191 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [2/27]

TEST_F ( MetadataUpdate  ,
MetadataTimestampNotNull   
)

Definition at line 193 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

193  {
194  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
195  return;
196  }
197 
198  make_table_cycler("timestamp_not_null_table", "timestamp not null")([&] {
199  query("insert into timestamp_not_null_table values ('1946-06-14 10:54:00');");
200  query("insert into timestamp_not_null_table values ('2017-01-20 12:00:00');");
201 
202  auto pre_metadata = get_metadata_vec("timestamp_not_null_table");
203  ASSERT_EQ(pre_metadata.size(), 1U);
204  auto pre_metadata_chunk = pre_metadata[0].second;
205 
206  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
207  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
208 
209  // Should throw
210  EXPECT_THROW(query("update timestamp_not_null_table set x = NULL where x < "
211  "'2000-01-01 00:00:00';"),
212  std::runtime_error);
213 
214  // This query currently flips has_null to true; may need correcting
215  // query( "insert into timestamp_not_null_table values ('-9223372036854775808');" );
216 
217  // This throws because it complains about NULL into a NOT NULL column, but it should
218  // accept the non-null token.
219  EXPECT_THROW(query("update timestamp_not_null_table set x='-9223372036854775808' "
220  "where x < '2000-01-01 00:00:00';"),
221  std::runtime_error);
222  auto post_metadata = get_metadata_vec("timestamp_not_null_table");
223  ASSERT_EQ(post_metadata.size(), 1U);
224  auto post_metadata_chunk = post_metadata[0].second;
225 
226  // This should never flip to true if it's a not-null table
227  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, false);
228 
229  query(
230  "update timestamp_not_null_table set x=cast('-9223372036854775807' as timestamp) "
231  "where x < '2000-01-01 00:00:00';");
232  query(
233  "update timestamp_not_null_table set x=cast('29379542399' as timestamp) where x "
234  "> '2000-01-01 00:00:00';");
235 
236  post_metadata = get_metadata_vec("timestamp_not_null_table");
237  ASSERT_EQ(post_metadata.size(), 1U);
238  post_metadata_chunk = post_metadata[0].second;
239 
240  // Because there is no range checking, we have to just check
241  // that this unwieldy value ended up making it to the minval anyway
242  int64_t post_timestamp_minval =
243  static_cast<int64_t>(post_metadata_chunk.chunkStats.min.bigintval);
244  int64_t post_timestamp_maxval =
245  static_cast<int64_t>(post_metadata_chunk.chunkStats.max.bigintval);
246  ASSERT_EQ(post_timestamp_minval, -9223372036854775807);
247  ASSERT_EQ(post_timestamp_maxval, 29379542399);
248 
249  // Check out-of-range max timestamp update
250  query(
251  "update timestamp_not_null_table set x=cast('9223372036854775807' as timestamp) "
252  "where x < '2000-01-01 00:00:00';");
253  post_metadata = get_metadata_vec("timestamp_not_null_table");
254  ASSERT_EQ(post_metadata.size(), 1U);
255  post_metadata_chunk = post_metadata[0].second;
256  post_timestamp_maxval =
257  static_cast<int64_t>(post_metadata_chunk.chunkStats.max.bigintval);
258 
259  ASSERT_EQ(post_timestamp_maxval, 9223372036854775807);
260  });
261 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [3/27]

TEST_F ( MetadataUpdate  ,
MetadataTimeNull   
)

Definition at line 263 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

263  {
264  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
265  return;
266  }
267 
268  make_table_cycler("time_null_table", "time")([&] {
269  query("insert into time_null_table values ('10:54:00');");
270  query("insert into time_null_table values ('12:00:00');");
271 
272  auto pre_metadata = get_metadata_vec("time_null_table");
273  ASSERT_EQ(pre_metadata.size(), 1U);
274  auto pre_metadata_chunk = pre_metadata[0].second;
275 
276  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
277  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
278 
279  query("update time_null_table set x = NULL where x < '12:00:00';");
280 
281  auto post_metadata = get_metadata_vec("time_null_table");
282  ASSERT_EQ(post_metadata.size(), 1U);
283  auto post_metadata_chunk = post_metadata[0].second;
284 
285  // Check that a null update doesn't change the before and after min-max
286  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.bigintval,
287  post_metadata_chunk.chunkStats.min.bigintval);
288  ASSERT_EQ(post_metadata_chunk.chunkStats.max.bigintval,
289  post_metadata_chunk.chunkStats.max.bigintval);
290  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
291 
292  query("update time_null_table set x='00:00:00' where x is NULL;");
293  post_metadata = get_metadata_vec("time_null_table");
294  ASSERT_EQ(post_metadata.size(), 1U);
295  post_metadata_chunk = post_metadata[0].second;
296 
297  auto time_minval = post_metadata_chunk.chunkStats.min.bigintval;
298  ASSERT_EQ(time_minval, 0);
299  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
300 
301  // Set the max, then verify that the min/max are the max possible for time ranges
302  // and also verify that the has null is still true
303  query("update time_null_table set x='23:59:59.999' where x='12:00:00';");
304  post_metadata = get_metadata_vec("time_null_table");
305  ASSERT_EQ(post_metadata.size(), 1U);
306  post_metadata_chunk = post_metadata[0].second;
307 
308  ASSERT_EQ(post_metadata_chunk.chunkStats.max.bigintval, 86399);
309  ASSERT_EQ(post_metadata_chunk.chunkStats.min.bigintval, 0);
310  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
311  ASSERT_GT(post_metadata_chunk.chunkStats.max.bigintval,
312  pre_metadata_chunk.chunkStats.max.bigintval);
313  ASSERT_LT(post_metadata_chunk.chunkStats.min.bigintval,
314  pre_metadata_chunk.chunkStats.min.bigintval);
315 
316  EXPECT_THROW(query("update time_null_table set x=cast('-9223372036854775807' as "
317  "time) where x = '00:00:00';"),
318  std::runtime_error);
319  EXPECT_THROW(query("update time_null_table set x=cast('9223372036854775807' as time) "
320  "where x = '23:59:59';"),
321  std::runtime_error);
322  });
323 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [4/27]

TEST_F ( MetadataUpdate  ,
MetadataTimeNotNull   
)

Definition at line 325 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

325  {
326  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
327  return;
328  }
329 
330  make_table_cycler("time_not_null_table", "time not null")([&] {
331  query("insert into time_not_null_table values ('10:54:00');");
332  query("insert into time_not_null_table values ('12:00:00');");
333 
334  auto pre_metadata = get_metadata_vec("time_not_null_table");
335  ASSERT_EQ(pre_metadata.size(), 1U);
336  auto pre_metadata_chunk = pre_metadata[0].second;
337 
338  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
339  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
340 
341  // Should throw
342  EXPECT_THROW(query("update time_not_null_table set x = NULL where x < "
343  "'12:00:00';"),
344  std::runtime_error);
345 
346  EXPECT_THROW(query("update time_not_null_table set x=cast('-9223372036854775808' as "
347  "time) where x < '12:00:00';"),
348  std::runtime_error);
349  auto post_metadata = get_metadata_vec("time_not_null_table");
350  ASSERT_EQ(post_metadata.size(), 1U);
351  auto post_metadata_chunk = post_metadata[0].second;
352 
353  // This should never flip to true if it's a not-null table
354  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, false);
355 
356  EXPECT_THROW(query("update time_not_null_table set x=cast('-9223372036854775807' as "
357  "time) where x < '12:00:00';"),
358  std::runtime_error);
359  EXPECT_THROW(query("update time_not_null_table set x=cast('9223372036854775807' as "
360  "time) where x > '2000-01-01 00:00:00';"),
361  std::runtime_error);
362 
363  query("update time_not_null_table set x='23:59:59.999' where x='12:00:00';");
364  query("update time_not_null_table set x='00:00:00' where x='10:54:00';");
365 
366  post_metadata = get_metadata_vec("time_not_null_table");
367  ASSERT_EQ(post_metadata.size(), 1U);
368  post_metadata_chunk = post_metadata[0].second;
369 
370  ASSERT_EQ(post_metadata_chunk.chunkStats.max.bigintval, 86399);
371  ASSERT_EQ(post_metadata_chunk.chunkStats.min.bigintval, 0);
372  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, false);
373  ASSERT_GT(post_metadata_chunk.chunkStats.max.bigintval,
374  pre_metadata_chunk.chunkStats.max.bigintval);
375  ASSERT_LT(post_metadata_chunk.chunkStats.min.bigintval,
376  pre_metadata_chunk.chunkStats.min.bigintval);
377  });
378 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [5/27]

TEST_F ( MetadataUpdate  ,
MetadataDateNull   
)

Definition at line 380 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

380  {
381  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
382  return;
383  }
384 
385  make_table_cycler("date_null_table", "date")([&] {
386  query("insert into date_null_table values ('1946-06-14');");
387  query("insert into date_null_table values ('1974-02-11');");
388 
389  auto pre_metadata = get_metadata_vec("date_null_table");
390  ASSERT_EQ(pre_metadata.size(), 1U);
391  auto pre_metadata_chunk = pre_metadata[0].second;
392 
393  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
394  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
395 
396  query("update date_null_table set x = NULL where x < '1950-01-01'");
397 
398  auto post_metadata = get_metadata_vec("date_null_table");
399  ASSERT_EQ(post_metadata.size(), 1U);
400  auto post_metadata_chunk = post_metadata[0].second;
401 
402  // Check that a null update doesn't change the before and after min-max
403  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.bigintval,
404  post_metadata_chunk.chunkStats.min.bigintval);
405  ASSERT_EQ(post_metadata_chunk.chunkStats.max.bigintval,
406  post_metadata_chunk.chunkStats.max.bigintval);
407  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
408 
409  query("update date_null_table set x='-185542587187199' where x is NULL;");
410  post_metadata = get_metadata_vec("date_null_table");
411  ASSERT_EQ(post_metadata.size(), 1U);
412  post_metadata_chunk = post_metadata[0].second;
413 
414  auto date_minval = post_metadata_chunk.chunkStats.min.bigintval;
415  EXPECT_EQ(date_minval, -185542587187200);
416  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
417 
418  query("update date_null_table set x='185542587187199' where x>'1950-01-01';");
419  post_metadata = get_metadata_vec("date_null_table");
420  ASSERT_EQ(post_metadata.size(), 1U);
421  post_metadata_chunk = post_metadata[0].second;
422 
423  EXPECT_EQ(post_metadata_chunk.chunkStats.max.bigintval, 185542587100800);
424  EXPECT_EQ(post_metadata_chunk.chunkStats.min.bigintval, -185542587187200);
425  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
426  ASSERT_GT(post_metadata_chunk.chunkStats.max.bigintval,
427  pre_metadata_chunk.chunkStats.max.bigintval);
428  ASSERT_LT(post_metadata_chunk.chunkStats.min.bigintval,
429  pre_metadata_chunk.chunkStats.min.bigintval);
430  });
431 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [6/27]

TEST_F ( MetadataUpdate  ,
MetadataDecimalNull   
)

Definition at line 433 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

433  {
434  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
435  return;
436  }
437 
438  make_table_cycler("decimal_null_table", "decimal(18,1)")([&] {
439  query("insert into decimal_null_table values ( 10.1 );");
440  query("insert into decimal_null_table values ( 20.1 );");
441 
442  auto pre_metadata = get_metadata_vec("decimal_null_table");
443  ASSERT_EQ(pre_metadata.size(), 1U);
444  auto pre_metadata_chunk = pre_metadata[0].second;
445 
446  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
447  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
448 
449  query("update decimal_null_table set x = NULL where x < 15;");
450 
451  auto post_metadata = get_metadata_vec("decimal_null_table");
452  ASSERT_EQ(post_metadata.size(), 1U);
453  auto post_metadata_chunk = post_metadata[0].second;
454 
455  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.bigintval,
456  post_metadata_chunk.chunkStats.min.bigintval);
457  ASSERT_EQ(post_metadata_chunk.chunkStats.max.bigintval,
458  post_metadata_chunk.chunkStats.max.bigintval);
459  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
460 
461  EXPECT_THROW(query("update decimal_null_table set x = -922337203685477580.7;"),
462  std::runtime_error);
463  EXPECT_THROW(query("update decimal_null_table set x = 922337203685477580.7;"),
464  std::runtime_error);
465 
466  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.bigintval,
467  post_metadata_chunk.chunkStats.min.bigintval);
468  ASSERT_EQ(post_metadata_chunk.chunkStats.max.bigintval,
469  post_metadata_chunk.chunkStats.max.bigintval);
470  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
471 
472  query("update decimal_null_table set x = 10.0 where x is NULL;");
473  query("update decimal_null_table set x = 20.2 where x > 15;");
474 
475  post_metadata = get_metadata_vec("decimal_null_table");
476  ASSERT_EQ(post_metadata.size(), 1U);
477  post_metadata_chunk = post_metadata[0].second;
478 
479  ASSERT_EQ(post_metadata_chunk.chunkStats.min.bigintval, 100);
480  ASSERT_EQ(post_metadata_chunk.chunkStats.max.bigintval, 202);
481  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
482  });
483 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [7/27]

TEST_F ( MetadataUpdate  ,
MetadataDecimalNotNull   
)

Definition at line 485 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

485  {
486  make_table_cycler("decimal_not_null_table", "decimal(18,1) not null")([&] {
487  query("insert into decimal_not_null_table values ( 10.1 );");
488  query("insert into decimal_not_null_table values ( 20.1 );");
489 
490  auto pre_metadata = get_metadata_vec("decimal_not_null_table");
491  ASSERT_EQ(pre_metadata.size(), 1U);
492  auto pre_metadata_chunk = pre_metadata[0].second;
493 
494  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
495  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
496 
497  EXPECT_THROW(query("update decimal_not_null_table set x = NULL where x < 15;"),
498  std::runtime_error);
499 
500  auto post_metadata = get_metadata_vec("decimal_not_null_table");
501  ASSERT_EQ(post_metadata.size(), 1U);
502  auto post_metadata_chunk = post_metadata[0].second;
503 
504  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.bigintval,
505  post_metadata_chunk.chunkStats.min.bigintval);
506  ASSERT_EQ(post_metadata_chunk.chunkStats.max.bigintval,
507  post_metadata_chunk.chunkStats.max.bigintval);
508  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, false);
509 
510  EXPECT_THROW(query("update decimal_not_null_table set x = -922337203685477580.7;"),
511  std::runtime_error);
512  EXPECT_THROW(query("update decimal_not_null_table set x = 922337203685477580.7;"),
513  std::runtime_error);
514 
515  query("update decimal_not_null_table set x = 10.0 where x < 15;");
516  query("update decimal_not_null_table set x = 20.2 where x > 15;");
517 
518  post_metadata = get_metadata_vec("decimal_not_null_table");
519  ASSERT_EQ(post_metadata.size(), 1U);
520  post_metadata_chunk = post_metadata[0].second;
521 
522  ASSERT_EQ(post_metadata_chunk.chunkStats.min.bigintval, 100);
523  ASSERT_EQ(post_metadata_chunk.chunkStats.max.bigintval, 202);
524  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, false);
525  });
526 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [8/27]

TEST_F ( MetadataUpdate  ,
MetadataIntegerNull   
)

Definition at line 528 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

528  {
529  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
530  return;
531  }
532 
533  make_table_cycler("integer_null_table", "integer")([&] {
534  query("insert into integer_null_table values (10);");
535  query("insert into integer_null_table values (20);");
536 
537  auto pre_metadata = get_metadata_vec("integer_null_table");
538  ASSERT_EQ(pre_metadata.size(), 1U);
539  auto pre_metadata_chunk = pre_metadata[0].second;
540 
541  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
542  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
543 
544  query("update integer_null_table set x = NULL where x < 15;");
545 
546  auto post_metadata = get_metadata_vec("integer_null_table");
547  ASSERT_EQ(post_metadata.size(), 1U);
548  auto post_metadata_chunk = post_metadata[0].second;
549 
550  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.intval,
551  post_metadata_chunk.chunkStats.min.intval);
552  ASSERT_EQ(post_metadata_chunk.chunkStats.max.intval,
553  post_metadata_chunk.chunkStats.max.intval);
554  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
555 
556  query("update integer_null_table set x=-2147483647 where x is NULL;");
557  post_metadata = get_metadata_vec("integer_null_table");
558  ASSERT_EQ(post_metadata.size(), 1U);
559  post_metadata_chunk = post_metadata[0].second;
560 
561  auto int_minval = post_metadata_chunk.chunkStats.min.intval;
562  ASSERT_EQ(int_minval, -2147483647);
563  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
564 
565  query("update integer_null_table set x=2147483647 where x > 15;");
566  post_metadata = get_metadata_vec("integer_null_table");
567  ASSERT_EQ(post_metadata.size(), 1U);
568  post_metadata_chunk = post_metadata[0].second;
569 
570  ASSERT_EQ(post_metadata_chunk.chunkStats.max.intval, 2147483647);
571  ASSERT_EQ(post_metadata_chunk.chunkStats.min.intval, -2147483647);
572  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
573  ASSERT_GT(post_metadata_chunk.chunkStats.max.intval,
574  pre_metadata_chunk.chunkStats.max.intval);
575  ASSERT_LT(post_metadata_chunk.chunkStats.min.intval,
576  pre_metadata_chunk.chunkStats.min.intval);
577  });
578 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [9/27]

TEST_F ( MetadataUpdate  ,
IntegerNotNull   
)

Definition at line 580 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

580  {
581  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
582  return;
583  }
584 
585  make_table_cycler("integer_not_null_table", "integer not null")([&] {
586  query("insert into integer_not_null_table values (10);");
587  query("insert into integer_not_null_table values (20);");
588 
589  auto pre_metadata = get_metadata_vec("integer_not_null_table");
590  ASSERT_EQ(pre_metadata.size(), 1U);
591  auto pre_metadata_chunk = pre_metadata[0].second;
592 
593  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
594  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
595 
596  EXPECT_THROW(query("update integer_not_null_table set x = NULL where x < 15;"),
597  std::runtime_error);
598  EXPECT_THROW(query("update integer_not_null_table set x = -2147483648 where x < 15;"),
599  std::runtime_error);
600  auto post_metadata = get_metadata_vec("integer_not_null_table");
601  ASSERT_EQ(post_metadata.size(), 1U);
602  auto post_metadata_chunk = post_metadata[0].second;
603 
604  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, false);
605 
606  query("update integer_not_null_table set x=-2147483647 where x < 15;");
607  query("update integer_not_null_table set x=2147483647 where x > 15;");
608 
609  post_metadata = get_metadata_vec("integer_not_null_table");
610  ASSERT_EQ(post_metadata.size(), 1U);
611  post_metadata_chunk = post_metadata[0].second;
612 
613  // Because there is no range checking, we have to just check
614  // that this unwieldy value ended up making it to the minval anyway
615  int64_t post_integer_minval =
616  static_cast<int64_t>(post_metadata_chunk.chunkStats.min.intval);
617  int64_t post_integer_maxval =
618  static_cast<int64_t>(post_metadata_chunk.chunkStats.max.intval);
619  ASSERT_EQ(post_integer_minval, -2147483647);
620  ASSERT_EQ(post_integer_maxval, 2147483647);
621 
622  // Check out-of-range max
623  EXPECT_THROW(query("update integer_not_null_table set x=2147483647+12 where x < 15;"),
624  std::runtime_error);
625 
626  post_metadata = get_metadata_vec("integer_not_null_table");
627  ASSERT_EQ(post_metadata.size(), 1U);
628  post_metadata_chunk = post_metadata[0].second;
629  post_integer_maxval = static_cast<int64_t>(post_metadata_chunk.chunkStats.max.intval);
630 
631  ASSERT_EQ(post_integer_maxval, 2147483647);
632  });
633 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [10/27]

TEST_F ( MetadataUpdate  ,
MetadataTinyIntNull   
)

Definition at line 635 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

635  {
636  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
637  return;
638  }
639 
640  make_table_cycler("tinyint_null_table", "tinyint")([&] {
641  query("insert into tinyint_null_table values (10);");
642  query("insert into tinyint_null_table values (20);");
643 
644  auto pre_metadata = get_metadata_vec("tinyint_null_table");
645  ASSERT_EQ(pre_metadata.size(), 1U);
646  auto pre_metadata_chunk = pre_metadata[0].second;
647 
648  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
649  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
650 
651  query("update tinyint_null_table set x = NULL where x < 15;");
652 
653  auto post_metadata = get_metadata_vec("tinyint_null_table");
654  ASSERT_EQ(post_metadata.size(), 1U);
655  auto post_metadata_chunk = post_metadata[0].second;
656 
657  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.tinyintval,
658  post_metadata_chunk.chunkStats.min.tinyintval);
659  ASSERT_EQ(post_metadata_chunk.chunkStats.max.tinyintval,
660  post_metadata_chunk.chunkStats.max.tinyintval);
661  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
662 
663  query("update tinyint_null_table set x=-127 where x is NULL;");
664  post_metadata = get_metadata_vec("tinyint_null_table");
665  ASSERT_EQ(post_metadata.size(), 1U);
666  post_metadata_chunk = post_metadata[0].second;
667 
668  auto tinyint_minval = post_metadata_chunk.chunkStats.min.tinyintval;
669  ASSERT_EQ(tinyint_minval, -127);
670  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
671 
672  query("update tinyint_null_table set x=127 where x > 15;");
673  post_metadata = get_metadata_vec("tinyint_null_table");
674  ASSERT_EQ(post_metadata.size(), 1U);
675  post_metadata_chunk = post_metadata[0].second;
676 
677  ASSERT_EQ(post_metadata_chunk.chunkStats.max.tinyintval, 127);
678  ASSERT_EQ(post_metadata_chunk.chunkStats.min.tinyintval, -127);
679  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
680  ASSERT_GT(post_metadata_chunk.chunkStats.max.tinyintval,
681  pre_metadata_chunk.chunkStats.max.tinyintval);
682  ASSERT_LT(post_metadata_chunk.chunkStats.min.tinyintval,
683  pre_metadata_chunk.chunkStats.min.tinyintval);
684  });
685 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [11/27]

TEST_F ( MetadataUpdate  ,
MetadataTinyIntNotNull   
)

Definition at line 687 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

687  {
688  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
689  return;
690  }
691 
692  make_table_cycler("tinyint_not_null_table", "tinyint not null")([&] {
693  query("insert into tinyint_not_null_table values (10);");
694  query("insert into tinyint_not_null_table values (20);");
695 
696  auto pre_metadata = get_metadata_vec("tinyint_not_null_table");
697  ASSERT_EQ(pre_metadata.size(), 1U);
698  auto pre_metadata_chunk = pre_metadata[0].second;
699 
700  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
701  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
702 
703  EXPECT_THROW(query("update tinyint_not_null_table set x = NULL where x < 15;"),
704  std::runtime_error);
705  EXPECT_THROW(query("update tinyint_not_null_table set x = -128 where x < 15;"),
706  std::runtime_error);
707  auto post_metadata = get_metadata_vec("tinyint_not_null_table");
708  ASSERT_EQ(post_metadata.size(), 1U);
709  auto post_metadata_chunk = post_metadata[0].second;
710 
711  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, false);
712 
713  query("update tinyint_not_null_table set x=-127 where x < 15;");
714  query("update tinyint_not_null_table set x=127 where x > 15;");
715 
716  post_metadata = get_metadata_vec("tinyint_not_null_table");
717  ASSERT_EQ(post_metadata.size(), 1U);
718  post_metadata_chunk = post_metadata[0].second;
719 
720  // Because there is no range checking, we have to just check
721  // that this unwieldy value ended up making it to the minval anyway
722  int64_t post_tinyint_minval =
723  static_cast<int64_t>(post_metadata_chunk.chunkStats.min.tinyintval);
724  int64_t post_tinyint_maxval =
725  static_cast<int64_t>(post_metadata_chunk.chunkStats.max.tinyintval);
726  ASSERT_EQ(post_tinyint_minval, -127);
727  ASSERT_EQ(post_tinyint_maxval, 127);
728 
729  // Check out-of-range max -- should wrap around to -117 here, then not widen the
730  // metadata
731  EXPECT_THROW(query("update tinyint_not_null_table set x=127+12 where x < 15;"),
732  std::runtime_error);
733 
734  post_metadata = get_metadata_vec("tinyint_not_null_table");
735  ASSERT_EQ(post_metadata.size(), 1U);
736  post_metadata_chunk = post_metadata[0].second;
737  post_tinyint_maxval =
738  static_cast<int64_t>(post_metadata_chunk.chunkStats.max.tinyintval);
739  post_tinyint_minval =
740  static_cast<int64_t>(post_metadata_chunk.chunkStats.min.tinyintval);
741 
742  ASSERT_EQ(post_tinyint_maxval, 127);
743  ASSERT_EQ(post_tinyint_minval, -127);
744  });
745 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [12/27]

TEST_F ( MetadataUpdate  ,
MetadataAddColumnWithDeletes   
)

Definition at line 747 of file UpdateMetadataTest.cpp.

References CPU, anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), anonymous_namespace{UpdateMetadataTest.cpp}::query, run-benchmark-import::result, run_ddl_statement(), and run_multiple_agg().

747  {
748  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
749  return;
750  }
751 
752  make_table_cycler("numbers", "int")([&] {
753  query("insert into numbers values (1);");
754  query("insert into numbers values (2);");
755  query("insert into numbers values (3);");
756  query("insert into numbers values (4);");
757 
758  {
759  auto result =
760  run_multiple_agg("select count(*) from numbers", ExecutorDeviceType::CPU);
761  const auto row = result->getNextRow(false, false);
762  ASSERT_EQ(row.size(), size_t(1));
763  ASSERT_EQ(TestHelpers::v<int64_t>(row[0]), int64_t(4));
764  }
765 
766  query("delete from numbers where x > 2;");
767 
768  {
769  auto result =
770  run_multiple_agg("select count(*) from numbers", ExecutorDeviceType::CPU);
771  const auto row = result->getNextRow(false, false);
772  ASSERT_EQ(row.size(), size_t(1));
773  ASSERT_EQ(TestHelpers::v<int64_t>(row[0]), int64_t(2));
774  }
775 
776  auto pre_metadata = get_metadata_vec("numbers", "$deleted$");
777  ASSERT_EQ(pre_metadata.size(), 1U);
778  auto pre_metadata_chunk = pre_metadata[0].second;
779 
780  ASSERT_EQ(pre_metadata_chunk.numElements, 4U);
781  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.tinyintval, int8_t(0));
782  ASSERT_EQ(pre_metadata_chunk.chunkStats.max.tinyintval, int8_t(1));
783  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
784 
785  run_ddl_statement("alter table numbers add column zebra int;");
786 
787  auto post_metadata = get_metadata_vec("numbers", "$deleted$");
788  ASSERT_EQ(post_metadata.size(), 1U);
789  auto post_metadata_chunk = post_metadata[0].second;
790 
791  ASSERT_EQ(post_metadata_chunk.numElements, 4U);
792  ASSERT_EQ(post_metadata_chunk.chunkStats.min.tinyintval, int8_t(0));
793  ASSERT_EQ(post_metadata_chunk.chunkStats.max.tinyintval, int8_t(1));
794  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, false);
795  });
796 }
auto make_table_cycler(char const *table_name, char const *column_type)
void run_ddl_statement(std::string ddl)
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

◆ TEST_F() [13/27]

TEST_F ( MetadataUpdate  ,
MetadataSmallIntNull   
)

Definition at line 798 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

798  {
799  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
800  return;
801  }
802 
803  make_table_cycler("smallint_null_table", "smallint")([&] {
804  query("insert into smallint_null_table values (10);");
805  query("insert into smallint_null_table values (20);");
806 
807  auto pre_metadata = get_metadata_vec("smallint_null_table");
808  ASSERT_EQ(pre_metadata.size(), 1U);
809  auto pre_metadata_chunk = pre_metadata[0].second;
810 
811  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
812  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
813 
814  query("update smallint_null_table set x = NULL where x < 15;");
815 
816  auto post_metadata = get_metadata_vec("smallint_null_table");
817  ASSERT_EQ(post_metadata.size(), 1U);
818  auto post_metadata_chunk = post_metadata[0].second;
819 
820  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.smallintval,
821  post_metadata_chunk.chunkStats.min.smallintval);
822  ASSERT_EQ(post_metadata_chunk.chunkStats.max.smallintval,
823  post_metadata_chunk.chunkStats.max.smallintval);
824  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
825 
826  query("update smallint_null_table set x=-32767 where x is NULL;");
827  post_metadata = get_metadata_vec("smallint_null_table");
828  ASSERT_EQ(post_metadata.size(), 1U);
829  post_metadata_chunk = post_metadata[0].second;
830 
831  auto smallint_minval = post_metadata_chunk.chunkStats.min.smallintval;
832  ASSERT_EQ(smallint_minval, -32767);
833  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
834 
835  query("update smallint_null_table set x=32767 where x > 15;");
836  post_metadata = get_metadata_vec("smallint_null_table");
837  ASSERT_EQ(post_metadata.size(), 1U);
838  post_metadata_chunk = post_metadata[0].second;
839 
840  ASSERT_EQ(post_metadata_chunk.chunkStats.max.smallintval, 32767);
841  ASSERT_EQ(post_metadata_chunk.chunkStats.min.smallintval, -32767);
842  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
843  ASSERT_GT(post_metadata_chunk.chunkStats.max.smallintval,
844  pre_metadata_chunk.chunkStats.max.smallintval);
845  ASSERT_LT(post_metadata_chunk.chunkStats.min.smallintval,
846  pre_metadata_chunk.chunkStats.min.smallintval);
847  });
848 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [14/27]

TEST_F ( MetadataUpdate  ,
MetadataSmallIntNotNull   
)

Definition at line 850 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

850  {
851  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
852  return;
853  }
854 
855  make_table_cycler("smallint_not_null_table", "smallint not null")([&] {
856  query("insert into smallint_not_null_table values (10);");
857  query("insert into smallint_not_null_table values (20);");
858 
859  auto pre_metadata = get_metadata_vec("smallint_not_null_table");
860  ASSERT_EQ(pre_metadata.size(), 1U);
861  auto pre_metadata_chunk = pre_metadata[0].second;
862 
863  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
864  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
865 
866  EXPECT_THROW(query("update smallint_not_null_table set x = NULL where x < 15;"),
867  std::runtime_error);
868  EXPECT_THROW(query("update smallint_not_null_table set x = -32768 where x < 15;"),
869  std::runtime_error);
870  auto post_metadata = get_metadata_vec("smallint_not_null_table");
871  ASSERT_EQ(post_metadata.size(), 1U);
872  auto post_metadata_chunk = post_metadata[0].second;
873 
874  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, false);
875 
876  query("update smallint_not_null_table set x=-32767 where x < 15;");
877  query("update smallint_not_null_table set x=32767 where x > 15;");
878 
879  post_metadata = get_metadata_vec("smallint_not_null_table");
880  ASSERT_EQ(post_metadata.size(), 1U);
881  post_metadata_chunk = post_metadata[0].second;
882 
883  // Because there is no range checking, we have to just check
884  // that this unwieldy value ended up making it to the minval anyway
885  int64_t post_smallint_minval =
886  static_cast<int64_t>(post_metadata_chunk.chunkStats.min.smallintval);
887  int64_t post_smallint_maxval =
888  static_cast<int64_t>(post_metadata_chunk.chunkStats.max.smallintval);
889  ASSERT_EQ(post_smallint_minval, -32767);
890  ASSERT_EQ(post_smallint_maxval, 32767);
891 
892  // Check out-of-range max -- should wrap around to -117 here, then not widen the
893  // metadata
894  EXPECT_THROW(query("update smallint_not_null_table set x=32767+12 where x < 15;"),
895  std::runtime_error);
896 
897  post_metadata = get_metadata_vec("smallint_not_null_table");
898  ASSERT_EQ(post_metadata.size(), 1U);
899  post_metadata_chunk = post_metadata[0].second;
900  post_smallint_maxval =
901  static_cast<int64_t>(post_metadata_chunk.chunkStats.max.smallintval);
902  post_smallint_minval =
903  static_cast<int64_t>(post_metadata_chunk.chunkStats.min.smallintval);
904 
905  ASSERT_EQ(post_smallint_maxval, 32767);
906  ASSERT_EQ(post_smallint_minval, -32767);
907  });
908 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [15/27]

TEST_F ( MetadataUpdate  ,
MetadataBigIntNull   
)

Definition at line 910 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

910  {
911  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
912  return;
913  }
914 
915  make_table_cycler("bigint_null_table", "bigint")([&] {
916  query("insert into bigint_null_table values (10);");
917  query("insert into bigint_null_table values (20);");
918 
919  auto pre_metadata = get_metadata_vec("bigint_null_table");
920  ASSERT_EQ(pre_metadata.size(), 1U);
921  auto pre_metadata_chunk = pre_metadata[0].second;
922 
923  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
924  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
925 
926  query("update bigint_null_table set x = NULL where x < 15;");
927 
928  auto post_metadata = get_metadata_vec("bigint_null_table");
929  ASSERT_EQ(post_metadata.size(), 1U);
930  auto post_metadata_chunk = post_metadata[0].second;
931 
932  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.bigintval,
933  post_metadata_chunk.chunkStats.min.bigintval);
934  ASSERT_EQ(post_metadata_chunk.chunkStats.max.bigintval,
935  post_metadata_chunk.chunkStats.max.bigintval);
936  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
937 
938  query("update bigint_null_table set x=-9223372036854775807 where x is NULL;");
939  post_metadata = get_metadata_vec("bigint_null_table");
940  ASSERT_EQ(post_metadata.size(), 1U);
941  post_metadata_chunk = post_metadata[0].second;
942 
943  auto bigint_minval = post_metadata_chunk.chunkStats.min.bigintval;
944  ASSERT_EQ(bigint_minval, -9223372036854775807);
945  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
946 
947  query("update bigint_null_table set x=9223372036854775807 where x > 15;");
948  post_metadata = get_metadata_vec("bigint_null_table");
949  ASSERT_EQ(post_metadata.size(), 1U);
950  post_metadata_chunk = post_metadata[0].second;
951 
952  ASSERT_EQ(post_metadata_chunk.chunkStats.max.bigintval, 9223372036854775807);
953  ASSERT_EQ(post_metadata_chunk.chunkStats.min.bigintval, -9223372036854775807);
954  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
955  ASSERT_GT(post_metadata_chunk.chunkStats.max.bigintval,
956  pre_metadata_chunk.chunkStats.max.bigintval);
957  ASSERT_LT(post_metadata_chunk.chunkStats.min.bigintval,
958  pre_metadata_chunk.chunkStats.min.bigintval);
959  });
960 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [16/27]

TEST_F ( MetadataUpdate  ,
MetadataBigIntNotNull   
)

Definition at line 962 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

962  {
963  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
964  return;
965  }
966 
967  make_table_cycler("bigint_not_null_table", "bigint not null")([&] {
968  query("insert into bigint_not_null_table values (10);");
969  query("insert into bigint_not_null_table values (20);");
970 
971  auto pre_metadata = get_metadata_vec("bigint_not_null_table");
972  ASSERT_EQ(pre_metadata.size(), 1U);
973  auto pre_metadata_chunk = pre_metadata[0].second;
974 
975  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
976  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
977 
978  EXPECT_THROW(query("update bigint_not_null_table set x = NULL where x < 15;"),
979  std::runtime_error);
980  EXPECT_THROW(
981  query("update bigint_not_null_table set x = -9223372036854775808 where x < 15;"),
982  std::runtime_error);
983  auto post_metadata = get_metadata_vec("bigint_not_null_table");
984  ASSERT_EQ(post_metadata.size(), 1U);
985  auto post_metadata_chunk = post_metadata[0].second;
986 
987  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, false);
988 
989  query("update bigint_not_null_table set x=-9223372036854775807 where x < 15;");
990  query("update bigint_not_null_table set x=9223372036854775807 where x > 15;");
991 
992  post_metadata = get_metadata_vec("bigint_not_null_table");
993  ASSERT_EQ(post_metadata.size(), 1U);
994  post_metadata_chunk = post_metadata[0].second;
995 
996  // Because there is no range checking, we have to just check
997  // that this unwieldy value ended up making it to the minval anyway
998  int64_t post_bigint_minval =
999  static_cast<int64_t>(post_metadata_chunk.chunkStats.min.bigintval);
1000  int64_t post_bigint_maxval =
1001  static_cast<int64_t>(post_metadata_chunk.chunkStats.max.bigintval);
1002  ASSERT_EQ(post_bigint_minval, -9223372036854775807);
1003  ASSERT_EQ(post_bigint_maxval, 9223372036854775807);
1004 
1005  // Check out-of-range max -- should wrap around to -117 here, then not widen the
1006  // metadata
1007  EXPECT_THROW(
1008  query("update bigint_not_null_table set x=9223372036854775807+12 where x < 15;"),
1009  std::runtime_error);
1010 
1011  post_metadata = get_metadata_vec("bigint_not_null_table");
1012  ASSERT_EQ(post_metadata.size(), 1U);
1013  post_metadata_chunk = post_metadata[0].second;
1014  post_bigint_maxval =
1015  static_cast<int64_t>(post_metadata_chunk.chunkStats.max.bigintval);
1016  post_bigint_minval =
1017  static_cast<int64_t>(post_metadata_chunk.chunkStats.min.bigintval);
1018 
1019  ASSERT_EQ(post_bigint_maxval, 9223372036854775807);
1020  ASSERT_EQ(post_bigint_minval, -9223372036854775807);
1021  });
1022 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [17/27]

TEST_F ( MetadataUpdate  ,
MetadataBooleanNull   
)

Definition at line 1024 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

1024  {
1025  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
1026  return;
1027  }
1028 
1029  make_table_cycler("boolean_null_table", "boolean")([&] {
1030  query("insert into boolean_null_table values ('f');");
1031 
1032  auto pre_metadata = get_metadata_vec("boolean_null_table");
1033  auto pre_metadata_chunk = pre_metadata[0].second;
1034 
1035  query("insert into boolean_null_table values ('t');");
1036 
1037  auto post_metadata = get_metadata_vec("boolean_null_table");
1038  auto post_metadata_chunk = post_metadata[0].second;
1039 
1040  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.tinyintval,
1041  post_metadata_chunk.chunkStats.min.tinyintval);
1042  ASSERT_LT(pre_metadata_chunk.chunkStats.max.tinyintval,
1043  post_metadata_chunk.chunkStats.max.tinyintval);
1044  });
1045 
1046  make_table_cycler("boolean_null_table", "boolean")([&] {
1047  query("insert into boolean_null_table values ('t');");
1048 
1049  auto pre_metadata = get_metadata_vec("boolean_null_table");
1050  auto pre_metadata_chunk = pre_metadata[0].second;
1051 
1052  query("insert into boolean_null_table values ('f');");
1053 
1054  auto post_metadata = get_metadata_vec("boolean_null_table");
1055  auto post_metadata_chunk = post_metadata[0].second;
1056 
1057  ASSERT_GT(pre_metadata_chunk.chunkStats.min.tinyintval,
1058  post_metadata_chunk.chunkStats.min.tinyintval);
1059  ASSERT_EQ(pre_metadata_chunk.chunkStats.max.tinyintval,
1060  post_metadata_chunk.chunkStats.max.tinyintval);
1061  });
1062 
1063  make_table_cycler("boolean_null_table", "boolean")([&] {
1064  query("insert into boolean_null_table values ('t');");
1065 
1066  auto pre_metadata = get_metadata_vec("boolean_null_table");
1067  auto pre_metadata_chunk = pre_metadata[0].second;
1068 
1069  query("insert into boolean_null_table values (NULL);");
1070 
1071  auto post_metadata = get_metadata_vec("boolean_null_table");
1072  auto post_metadata_chunk = post_metadata[0].second;
1073 
1074  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.tinyintval,
1075  post_metadata_chunk.chunkStats.min.tinyintval);
1076  ASSERT_EQ(pre_metadata_chunk.chunkStats.max.tinyintval,
1077  post_metadata_chunk.chunkStats.max.tinyintval);
1078  });
1079 
1080  make_table_cycler("boolean_null_table", "boolean")([&] {
1081  query("insert into boolean_null_table values ('f');");
1082 
1083  auto pre_metadata = get_metadata_vec("boolean_null_table");
1084  auto pre_metadata_chunk = pre_metadata[0].second;
1085 
1086  query("insert into boolean_null_table values (NULL);");
1087 
1088  auto post_metadata = get_metadata_vec("boolean_null_table");
1089  auto post_metadata_chunk = post_metadata[0].second;
1090 
1091  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.tinyintval,
1092  post_metadata_chunk.chunkStats.min.tinyintval);
1093  ASSERT_EQ(pre_metadata_chunk.chunkStats.max.tinyintval,
1094  post_metadata_chunk.chunkStats.max.tinyintval);
1095  });
1096 
1097  make_table_cycler("boolean_null_table", "boolean")([&] {
1098  query("insert into boolean_null_table values ('t');");
1099  query("insert into boolean_null_table values ('f');");
1100 
1101  auto pre_metadata = get_metadata_vec("boolean_null_table");
1102  ASSERT_EQ(pre_metadata.size(), 1U);
1103  auto pre_metadata_chunk = pre_metadata[0].second;
1104 
1105  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
1106  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
1107 
1108  query("update boolean_null_table set x = NULL where x = true;");
1109 
1110  auto post_metadata = get_metadata_vec("boolean_null_table");
1111  ASSERT_EQ(post_metadata.size(), 1U);
1112  auto post_metadata_chunk = post_metadata[0].second;
1113 
1114  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.tinyintval,
1115  post_metadata_chunk.chunkStats.min.tinyintval);
1116  ASSERT_EQ(post_metadata_chunk.chunkStats.max.tinyintval,
1117  post_metadata_chunk.chunkStats.max.tinyintval);
1118  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
1119 
1120  query("update boolean_null_table set x='f' where x is NULL;");
1121  post_metadata = get_metadata_vec("boolean_null_table");
1122  ASSERT_EQ(post_metadata.size(), 1U);
1123  post_metadata_chunk = post_metadata[0].second;
1124 
1125  auto tinyint_minval = post_metadata_chunk.chunkStats.min.tinyintval;
1126  ASSERT_EQ(tinyint_minval, 0);
1127  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
1128 
1129  query("update boolean_null_table set x=True where x = false;");
1130  post_metadata = get_metadata_vec("boolean_null_table");
1131  ASSERT_EQ(post_metadata.size(), 1U);
1132  post_metadata_chunk = post_metadata[0].second;
1133 
1134  ASSERT_EQ(post_metadata_chunk.chunkStats.max.tinyintval, 1);
1135  ASSERT_EQ(post_metadata_chunk.chunkStats.min.tinyintval, 0);
1136  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
1137  });
1138 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [18/27]

TEST_F ( MetadataUpdate  ,
MetadataBooleanNotNull   
)

Definition at line 1140 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

1140  {
1141  return;
1142 
1143  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
1144  return;
1145  }
1146 
1147  make_table_cycler("boolean_not_null_table", "boolean not null")([&] {
1148  query("insert into boolean_not_null_table values ('t');");
1149  query("insert into boolean_not_null_table values ('f');");
1150 
1151  auto pre_metadata = get_metadata_vec("boolean_not_null_table");
1152  ASSERT_EQ(pre_metadata.size(), 1U);
1153  auto pre_metadata_chunk = pre_metadata[0].second;
1154 
1155  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
1156  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
1157 
1158  EXPECT_THROW(query("update boolean_not_null_table set x = NULL where x = false"),
1159  std::runtime_error);
1160 
1161  auto post_metadata = get_metadata_vec("boolean_not_null_table");
1162  ASSERT_EQ(post_metadata.size(), 1U);
1163  auto post_metadata_chunk = post_metadata[0].second;
1164 
1165  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, false);
1166  });
1167 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [19/27]

TEST_F ( MetadataUpdate  ,
MetadataFloatNull   
)

Definition at line 1169 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

1169  {
1170  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
1171  return;
1172  }
1173 
1174  make_table_cycler("float_null_table", "float")([&] {
1175  query("insert into float_null_table values (10.1234);");
1176  query("insert into float_null_table values (20.4321);");
1177 
1178  auto pre_metadata = get_metadata_vec("float_null_table");
1179  ASSERT_EQ(pre_metadata.size(), 1U);
1180  auto pre_metadata_chunk = pre_metadata[0].second;
1181 
1182  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
1183  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
1184 
1185  query("update float_null_table set x = NULL where x < 15;");
1186 
1187  auto post_metadata = get_metadata_vec("float_null_table");
1188  ASSERT_EQ(post_metadata.size(), 1U);
1189  auto post_metadata_chunk = post_metadata[0].second;
1190 
1191  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.floatval,
1192  post_metadata_chunk.chunkStats.min.floatval);
1193  ASSERT_EQ(post_metadata_chunk.chunkStats.max.floatval,
1194  post_metadata_chunk.chunkStats.max.floatval);
1195  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
1196 
1197  query("update float_null_table set x=-3.40282E38 where x is NULL;");
1198  query("update float_null_table set x=3.40282E38 where x > 15;");
1199 
1200  post_metadata = get_metadata_vec("float_null_table");
1201  ASSERT_EQ(post_metadata.size(), 1U);
1202  post_metadata_chunk = post_metadata[0].second;
1203 
1204  ASSERT_FLOAT_EQ(post_metadata_chunk.chunkStats.max.floatval, 3.40282E38);
1205  ASSERT_FLOAT_EQ(post_metadata_chunk.chunkStats.min.floatval, -3.40282E38);
1206  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
1207  ASSERT_GT(post_metadata_chunk.chunkStats.max.floatval,
1208  pre_metadata_chunk.chunkStats.max.floatval);
1209  ASSERT_LT(post_metadata_chunk.chunkStats.min.floatval,
1210  pre_metadata_chunk.chunkStats.min.floatval);
1211  });
1212 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [20/27]

TEST_F ( MetadataUpdate  ,
MetadataFloatNotNull   
)

Definition at line 1214 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

1214  {
1215  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
1216  return;
1217  }
1218 
1219  make_table_cycler("float_not_null_table", "float not null")([&] {
1220  query("insert into float_not_null_table values (10.1234);");
1221  query("insert into float_not_null_table values (20.4321);");
1222 
1223  auto pre_metadata = get_metadata_vec("float_not_null_table");
1224  ASSERT_EQ(pre_metadata.size(), 1U);
1225  auto pre_metadata_chunk = pre_metadata[0].second;
1226 
1227  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
1228  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
1229 
1230  EXPECT_THROW(query("update float_not_null_table set x = NULL where x < 15;"),
1231  std::runtime_error);
1232 
1233  auto post_metadata = get_metadata_vec("float_not_null_table");
1234  ASSERT_EQ(post_metadata.size(), 1U);
1235  auto post_metadata_chunk = post_metadata[0].second;
1236 
1237  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.floatval,
1238  post_metadata_chunk.chunkStats.min.floatval);
1239  ASSERT_EQ(post_metadata_chunk.chunkStats.max.floatval,
1240  post_metadata_chunk.chunkStats.max.floatval);
1241  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, false);
1242 
1243  // Doesn't work on not null columns; still seen as null.
1244  // query( "update float_not_null_table set x = 1.175494351E-38 where x < 15;" );
1245  query("update float_not_null_table set x=3.40282E38 where x > 15;");
1246 
1247  post_metadata = get_metadata_vec("float_not_null_table");
1248  ASSERT_EQ(post_metadata.size(), 1U);
1249  post_metadata_chunk = post_metadata[0].second;
1250 
1251  ASSERT_FLOAT_EQ(post_metadata_chunk.chunkStats.max.floatval, 3.40282E38);
1252  // Removed; see comment just above.
1253  // ASSERT_FLOAT_EQ(post_metadata_chunk.chunkStats.min.floatval, 1.175494351E-38);
1254  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, false);
1255  ASSERT_GT(post_metadata_chunk.chunkStats.max.floatval,
1256  pre_metadata_chunk.chunkStats.max.floatval);
1257  ASSERT_FLOAT_EQ(post_metadata_chunk.chunkStats.min.floatval,
1258  pre_metadata_chunk.chunkStats.min.floatval);
1259  });
1260 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [21/27]

TEST_F ( MetadataUpdate  ,
MetadataDoubleNull   
)

Definition at line 1262 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

1262  {
1263  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
1264  return;
1265  }
1266 
1267  make_table_cycler("double_null_table", "double")([&] {
1268  query("insert into double_null_table values (10.1234);");
1269  query("insert into double_null_table values (20.4321);");
1270 
1271  auto pre_metadata = get_metadata_vec("double_null_table");
1272  ASSERT_EQ(pre_metadata.size(), 1U);
1273  auto pre_metadata_chunk = pre_metadata[0].second;
1274 
1275  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
1276  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
1277 
1278  query("update double_null_table set x = NULL where x < 15;");
1279 
1280  auto post_metadata = get_metadata_vec("double_null_table");
1281  ASSERT_EQ(post_metadata.size(), 1U);
1282  auto post_metadata_chunk = post_metadata[0].second;
1283 
1284  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.doubleval,
1285  post_metadata_chunk.chunkStats.min.doubleval);
1286  ASSERT_EQ(post_metadata_chunk.chunkStats.max.doubleval,
1287  post_metadata_chunk.chunkStats.max.doubleval);
1288  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
1289 
1290  query("update double_null_table set x=-1.79769313486231571E308 where x is NULL;");
1291  query("update double_null_table set x=1.79769313486231571e+308 where x > 15;");
1292 
1293  post_metadata = get_metadata_vec("double_null_table");
1294  ASSERT_EQ(post_metadata.size(), 1U);
1295  post_metadata_chunk = post_metadata[0].second;
1296 
1297  ASSERT_DOUBLE_EQ(post_metadata_chunk.chunkStats.max.doubleval,
1298  1.79769313486231571e+308);
1299  ASSERT_DOUBLE_EQ(post_metadata_chunk.chunkStats.min.doubleval,
1300  -1.79769313486231571e+308);
1301  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
1302  ASSERT_GT(post_metadata_chunk.chunkStats.max.doubleval,
1303  pre_metadata_chunk.chunkStats.max.doubleval);
1304  ASSERT_LT(post_metadata_chunk.chunkStats.min.doubleval,
1305  pre_metadata_chunk.chunkStats.min.doubleval);
1306  });
1307 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [22/27]

TEST_F ( MetadataUpdate  ,
MetadataDoubleNotNull   
)

Definition at line 1309 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

1309  {
1310  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
1311  return;
1312  }
1313 
1314  make_table_cycler("double_not_null_table", "double not null")([&] {
1315  query("insert into double_not_null_table values (10.1234);");
1316  query("insert into double_not_null_table values (20.4321);");
1317 
1318  auto pre_metadata = get_metadata_vec("double_not_null_table");
1319  ASSERT_EQ(pre_metadata.size(), 1U);
1320  auto pre_metadata_chunk = pre_metadata[0].second;
1321 
1322  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
1323  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
1324 
1325  EXPECT_THROW(query("update double_not_null_table set x = NULL where x < 15;"),
1326  std::runtime_error);
1327 
1328  auto post_metadata = get_metadata_vec("double_not_null_table");
1329  ASSERT_EQ(post_metadata.size(), 1U);
1330  auto post_metadata_chunk = post_metadata[0].second;
1331 
1332  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.doubleval,
1333  post_metadata_chunk.chunkStats.min.doubleval);
1334  ASSERT_EQ(post_metadata_chunk.chunkStats.max.doubleval,
1335  post_metadata_chunk.chunkStats.max.doubleval);
1336  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, false);
1337 
1338  // Doesn't work on not null columns; still seen as null.
1339  // query( "update double_not_null_table set x = 1.175494351E-38 where x < 15;" );
1340  query("update double_not_null_table set x=1.79769313486231571e+308 where x > 15;");
1341 
1342  post_metadata = get_metadata_vec("double_not_null_table");
1343  ASSERT_EQ(post_metadata.size(), 1U);
1344  post_metadata_chunk = post_metadata[0].second;
1345 
1346  ASSERT_DOUBLE_EQ(post_metadata_chunk.chunkStats.max.doubleval,
1347  1.79769313486231571e+308);
1348  // Removed; see comment just above.
1349  // ASSERT_DOUBLE_EQ(post_metadata_chunk.chunkStats.min.doubleval, 1.175494351E-38);
1350  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, false);
1351  ASSERT_GT(post_metadata_chunk.chunkStats.max.doubleval,
1352  pre_metadata_chunk.chunkStats.max.doubleval);
1353  ASSERT_DOUBLE_EQ(post_metadata_chunk.chunkStats.min.doubleval,
1354  pre_metadata_chunk.chunkStats.min.doubleval);
1355  });
1356 }
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [23/27]

TEST_F ( MetadataUpdate  ,
MetadataStringDict8Null   
)

Definition at line 1358 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), anonymous_namespace{UpdateMetadataTest.cpp}::query, and run_ddl_statement().

1358  {
1359  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
1360  return;
1361  }
1362 
1363  make_table_cycler("presidents", "text encoding dict(8)")([&] {
1364  query("insert into presidents values ('Ronald Reagan');");
1365  query("insert into presidents values ('Donald Trump');");
1366  query("insert into presidents values ('Dwight Eisenhower');");
1367  query("insert into presidents values ('Teddy Roosevelt');");
1368  query("insert into presidents values (NULL);");
1369 
1371  "alter table presidents add column presidents_copy text encoding dict(8);");
1372 
1373  auto pre_metadata = get_metadata_vec("presidents", "presidents_copy"s);
1374  auto pre_metadata_chunk = pre_metadata[0].second;
1375  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, true);
1376 
1377  query("update presidents set presidents_copy=x;");
1378  auto post_metadata = get_metadata_vec("presidents", "presidents_copy"s);
1379  ASSERT_EQ(post_metadata.size(), 1U);
1380  auto post_metadata_chunk = post_metadata[0].second;
1381 
1382  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
1383  ASSERT_EQ(post_metadata_chunk.chunkStats.min.intval, 0);
1384  ASSERT_EQ(post_metadata_chunk.chunkStats.max.intval, 3);
1385  });
1386 }
auto make_table_cycler(char const *table_name, char const *column_type)
void run_ddl_statement(std::string ddl)
+ Here is the call graph for this function:

◆ TEST_F() [24/27]

TEST_F ( MetadataUpdate  ,
MetadataStringDict16Null   
)

Definition at line 1388 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), anonymous_namespace{UpdateMetadataTest.cpp}::query, and run_ddl_statement().

1388  {
1389  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
1390  return;
1391  }
1392 
1393  make_table_cycler("safe_cities", "text encoding dict(16)")([&] {
1394  query("insert into safe_cities values ('El Paso');");
1395  query("insert into safe_cities values ('Pingyao');");
1396  query("insert into safe_cities values ('Veliky Novgorod');");
1397  query("insert into safe_cities values (NULL);");
1398 
1400  "alter table safe_cities add column safe_cities_copy text encoding dict(16);");
1401 
1402  auto pre_metadata = get_metadata_vec("safe_cities", "safe_cities_copy"s);
1403  auto pre_metadata_chunk = pre_metadata[0].second;
1404  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, true);
1405 
1406  query("update safe_cities set safe_cities_copy=x;");
1407  auto post_metadata = get_metadata_vec("safe_cities", "safe_cities_copy"s);
1408  ASSERT_EQ(post_metadata.size(), 1U);
1409  auto post_metadata_chunk = post_metadata[0].second;
1410 
1411  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
1412  ASSERT_EQ(post_metadata_chunk.chunkStats.min.intval, 0);
1413  ASSERT_EQ(post_metadata_chunk.chunkStats.max.intval, 2);
1414  });
1415 }
auto make_table_cycler(char const *table_name, char const *column_type)
void run_ddl_statement(std::string ddl)
+ Here is the call graph for this function:

◆ TEST_F() [25/27]

TEST_F ( MetadataUpdate  ,
MetadataStringDict32Null   
)

Definition at line 1417 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), anonymous_namespace{UpdateMetadataTest.cpp}::query, and run_ddl_statement().

1417  {
1418  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
1419  return;
1420  }
1421 
1422  make_table_cycler("candidates", "text encoding dict(32)")([&] {
1423  query("insert into candidates values ('Lightfoot');");
1424  query("insert into candidates values ('Wilson');");
1425  query("insert into candidates values ('Chico');");
1426  query("insert into candidates values ('Preckwinkle');");
1427  query("insert into candidates values ('Mendoza');");
1428  query("insert into candidates values (NULL);");
1429 
1431  "alter table candidates add column candidates_copy text encoding dict(16);");
1432 
1433  auto pre_metadata = get_metadata_vec("candidates", "candidates_copy"s);
1434  auto pre_metadata_chunk = pre_metadata[0].second;
1435  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, true);
1436 
1437  query("update candidates set candidates_copy=x;");
1438  auto post_metadata = get_metadata_vec("candidates", "candidates_copy"s);
1439  ASSERT_EQ(post_metadata.size(), 1U);
1440  auto post_metadata_chunk = post_metadata[0].second;
1441 
1442  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
1443  ASSERT_EQ(post_metadata_chunk.chunkStats.min.intval, 0);
1444  ASSERT_EQ(post_metadata_chunk.chunkStats.max.intval, 4);
1445  });
1446 }
auto make_table_cycler(char const *table_name, char const *column_type)
void run_ddl_statement(std::string ddl)
+ Here is the call graph for this function:

◆ TEST_F() [26/27]

TEST_F ( MetadataUpdate  ,
MetadataSmallIntEncodedNull   
)

Definition at line 1448 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

1448  {
1449  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
1450  return;
1451  }
1452 
1453  make_table_cycler("small_ints_null", "smallint encoding fixed(8)")([&] {
1454  query("insert into small_ints_null values (10);");
1455  query("insert into small_ints_null values (90);");
1456 
1457  auto pre_metadata = get_metadata_vec("small_ints_null");
1458  ASSERT_EQ(pre_metadata.size(), 1U);
1459  auto pre_metadata_chunk = pre_metadata[0].second;
1460 
1461  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
1462  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
1463 
1464  query("update small_ints_null set x = NULL where x < 50;");
1465 
1466  auto post_metadata = get_metadata_vec("small_ints_null");
1467  ASSERT_EQ(post_metadata.size(), 1U);
1468  auto post_metadata_chunk = post_metadata[0].second;
1469 
1470  ASSERT_EQ(pre_metadata_chunk.chunkStats.min.smallintval,
1471  post_metadata_chunk.chunkStats.min.smallintval);
1472  ASSERT_EQ(post_metadata_chunk.chunkStats.max.smallintval,
1473  post_metadata_chunk.chunkStats.max.smallintval);
1474  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
1475 
1476  auto smallint_minval = post_metadata_chunk.chunkStats.min.smallintval;
1477  ASSERT_EQ(smallint_minval, 10);
1478  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
1479 
1480  query("update small_ints_null set x=-127 where x is NULL;");
1481  query("update small_ints_null set x=127;");
1482 
1483  post_metadata = get_metadata_vec("small_ints_null");
1484  ASSERT_EQ(post_metadata.size(), 1U);
1485  post_metadata_chunk = post_metadata[0].second;
1486 
1487  ASSERT_EQ(post_metadata_chunk.chunkStats.max.smallintval, 127);
1488  ASSERT_EQ(post_metadata_chunk.chunkStats.min.smallintval, -127);
1489  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, true);
1490  ASSERT_GT(post_metadata_chunk.chunkStats.max.smallintval,
1491  pre_metadata_chunk.chunkStats.max.smallintval);
1492  ASSERT_LT(post_metadata_chunk.chunkStats.min.smallintval,
1493  pre_metadata_chunk.chunkStats.min.smallintval);
1494  });
1495 };
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function:

◆ TEST_F() [27/27]

TEST_F ( MetadataUpdate  ,
MetadataSmallIntEncodedNotNull   
)

Definition at line 1497 of file UpdateMetadataTest.cpp.

References anonymous_namespace{UpdateMetadataTest.cpp}::get_metadata_vec, anonymous_namespace{UpdateMetadataTest.cpp}::make_table_cycler(), and anonymous_namespace{UpdateMetadataTest.cpp}::query.

1497  {
1498  if (!is_feature_enabled<CalciteUpdatePathSelector>()) {
1499  return;
1500  }
1501 
1502  make_table_cycler("small_ints_not_null", "smallint not null encoding fixed(8)")([&] {
1503  query("insert into small_ints_not_null values (10);");
1504  query("insert into small_ints_not_null values (90);");
1505 
1506  auto pre_metadata = get_metadata_vec("small_ints_not_null");
1507  ASSERT_EQ(pre_metadata.size(), 1U);
1508  auto pre_metadata_chunk = pre_metadata[0].second;
1509 
1510  ASSERT_EQ(pre_metadata_chunk.numElements, 2U);
1511  ASSERT_EQ(pre_metadata_chunk.chunkStats.has_nulls, false);
1512 
1513  EXPECT_THROW(query("update small_ints_not_null set x = NULL where x < 50;"),
1514  std::runtime_error);
1515  auto post_metadata = get_metadata_vec("small_ints_not_null");
1516  ASSERT_EQ(post_metadata.size(), 1U);
1517  auto post_metadata_chunk = post_metadata[0].second;
1518 
1519  // This should never flip to true if it's a not-null table
1520  ASSERT_EQ(post_metadata_chunk.chunkStats.has_nulls, false);
1521 
1522  query("update small_ints_not_null set x=-127 where x < 50;");
1523  query("update small_ints_not_null set x=127 where x > 50;");
1524 
1525  post_metadata = get_metadata_vec("small_ints_not_null");
1526  ASSERT_EQ(post_metadata.size(), 1U);
1527  post_metadata_chunk = post_metadata[0].second;
1528 
1529  auto post_smallint_minval = post_metadata_chunk.chunkStats.min.smallintval;
1530  auto post_smallint_maxval = post_metadata_chunk.chunkStats.max.smallintval;
1531  ASSERT_EQ(post_smallint_minval, -127);
1532  ASSERT_EQ(post_smallint_maxval, 127);
1533  });
1534 };
auto make_table_cycler(char const *table_name, char const *column_type)
+ Here is the call graph for this function: