MCPcopy Create free account
hub / github.com/apache/impala / TestTimestamp

Method TestTimestamp

be/src/exprs/iceberg-functions-test.cc:552–616  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

550}
551
552void IcebergBucketPartitionTransformTests::TestTimestamp() {
553 TimestampVal tv;
554 TimestampValue::ParseSimpleDateFormat("2017-11-16 22:31:08").ToTimestampVal(&tv);
555 IntVal ret_val = IcebergFunctions::BucketPartitionTransform(nullptr, tv, 100);
556 EXPECT_EQ(7, ret_val.val);
557
558 TimestampValue::ParseSimpleDateFormat("2017-11-16 22:31:08").ToTimestampVal(&tv);
559 ret_val = IcebergFunctions::BucketPartitionTransform(nullptr, tv, 1150);
560 EXPECT_EQ(957, ret_val.val);
561
562 // Check that zero fractional seconts doesn't change the output.
563 TimestampValue::ParseSimpleDateFormat(
564 "2017-11-16 22:31:08.000000").ToTimestampVal(&tv);
565 ret_val = IcebergFunctions::BucketPartitionTransform(nullptr, tv, 100);
566 EXPECT_EQ(7, ret_val.val);
567
568 TimestampValue::ParseSimpleDateFormat(
569 "2017-11-16 22:31:08.000000000").ToTimestampVal(&tv);
570 ret_val = IcebergFunctions::BucketPartitionTransform(nullptr, tv, 100);
571 EXPECT_EQ(7, ret_val.val);
572
573 // Checks for non-zero fractional seconds.
574 TimestampValue::ParseSimpleDateFormat("2010-10-09 12:39:28.123").ToTimestampVal(&tv);
575 ret_val = IcebergFunctions::BucketPartitionTransform(nullptr, tv, 250);
576 EXPECT_EQ(107, ret_val.val);
577
578 TimestampValue::ParseSimpleDateFormat(
579 "2010-10-09 12:39:28.123456").ToTimestampVal(&tv);
580 ret_val = IcebergFunctions::BucketPartitionTransform(nullptr, tv, 250);
581 EXPECT_EQ(115, ret_val.val);
582
583 // Check that the 7th, 8th, 9th digit if the fractional second doesn't have effect on
584 // the result. This is to follow Iceberg's behaviour.
585 TimestampValue::ParseSimpleDateFormat(
586 "2010-10-09 12:39:28.123456789").ToTimestampVal(&tv);
587 ret_val = IcebergFunctions::BucketPartitionTransform(nullptr, tv, 250);
588 EXPECT_EQ(115, ret_val.val);
589
590 // Test for values pre 1970.
591 TimestampValue::ParseSimpleDateFormat(
592 "1905-01-02 12:20:25").ToTimestampVal(&tv);
593 ret_val = IcebergFunctions::BucketPartitionTransform(nullptr, tv, 2000);
594 EXPECT_EQ(809, ret_val.val);
595
596 TimestampValue::ParseSimpleDateFormat(
597 "1905-01-02 12:20:25.123456").ToTimestampVal(&tv);
598 ret_val = IcebergFunctions::BucketPartitionTransform(nullptr, tv, 2000);
599 EXPECT_EQ(932, ret_val.val);
600
601 TimestampValue::ParseSimpleDateFormat(
602 "1905-01-02 12:20:25.123456789").ToTimestampVal(&tv);
603 ret_val = IcebergFunctions::BucketPartitionTransform(nullptr, tv, 2000);
604 EXPECT_EQ(932, ret_val.val);
605
606 TimestampValue::ParseSimpleDateFormat(
607 "1905-01-02 12:20:25").ToTimestampVal(&tv);
608 ret_val = IcebergFunctions::BucketPartitionTransform(nullptr, tv, 8000);
609 EXPECT_EQ(2809, ret_val.val);

Callers

nothing calls this directly

Calls 2

TimestampValClass · 0.85
ToTimestampValMethod · 0.80

Tested by

no test coverage detected