kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danburk...@apache.org
Subject [1/2] kudu git commit: KUDU-1722 - Range Partition Failure on UNIXTIME_MICROS
Date Fri, 18 Nov 2016 02:00:52 GMT
Repository: kudu
Updated Branches:
  refs/heads/master b1d02ee1a -> b9453a258


KUDU-1722 - Range Partition Failure on UNIXTIME_MICROS

Errors are returned when attempting to add range partition bounds
for a unixtime_micros value when specifying bound types that are
not the default. This is happening because the logic to convert the
bounds to defaults (inclusive for Lower and exclusive for Upper)
converts the UNIXTIME_MICROS value to an INT64. This patch addresses
this issue and includes a test.

Change-Id: I47d23d184a6b73c5c0cdd04519821c4e7eb53ecb
Reviewed-on: http://gerrit.cloudera.org:8080/5119
Tested-by: Kudu Jenkins
Reviewed-by: Dan Burkert <danburkert@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/7a4fafe7
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/7a4fafe7
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/7a4fafe7

Branch: refs/heads/master
Commit: 7a4fafe79da19c6838c96955fbb39276f5675bd4
Parents: b1d02ee
Author: Jordan Birdsell <jordantbirdsell@gmail.com>
Authored: Thu Nov 17 00:02:34 2016 -0500
Committer: Jordan Birdsell <jtbirdsell@apache.org>
Committed: Thu Nov 17 21:18:03 2016 +0000

----------------------------------------------------------------------
 src/kudu/client/client-test.cc | 27 +++++++++++++++++++++++++++
 src/kudu/common/partition.cc   | 15 ++++++++++++---
 2 files changed, 39 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/7a4fafe7/src/kudu/client/client-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/client-test.cc b/src/kudu/client/client-test.cc
index c6ae8b8..a692b8f 100644
--- a/src/kudu/client/client-test.cc
+++ b/src/kudu/client/client-test.cc
@@ -1386,6 +1386,33 @@ TEST_F(ClientTest, TestExclusiveInclusiveRangeBounds) {
   ASSERT_EQ(0, CountTableRows(table.get()));
 }
 
+TEST_F(ClientTest, TestExclusiveInclusiveUnixTimeMicrosRangeBounds) {
+  // Create test table with range partition using non-default bound types.
+  // KUDU-1722
+  KuduSchemaBuilder builder;
+  KuduSchema u_schema_;
+  builder.AddColumn("key")->Type(KuduColumnSchema::UNIXTIME_MICROS)->NotNull()->PrimaryKey();
+  builder.AddColumn("value")->Type(KuduColumnSchema::INT32)->NotNull();
+  CHECK_OK(builder.Build(&u_schema_));
+  const string table_name = "TestExclusiveInclusiveUnixTimeMicrosRangeBounds";
+  shared_ptr<KuduTable> table;
+
+  unique_ptr<KuduPartialRow> lower_bound(u_schema_.NewRow());
+  ASSERT_OK(lower_bound->SetUnixTimeMicros("key", -1));
+  unique_ptr<KuduPartialRow> upper_bound(u_schema_.NewRow());
+  ASSERT_OK(upper_bound->SetUnixTimeMicros("key", 99));
+
+  gscoped_ptr<KuduTableCreator> table_creator(client_->NewTableCreator());
+  table_creator->add_range_partition(lower_bound.release(), upper_bound.release(),
+                                      KuduTableCreator::EXCLUSIVE_BOUND,
+                                      KuduTableCreator::INCLUSIVE_BOUND);
+  ASSERT_OK(table_creator->table_name(table_name)
+                          .schema(&u_schema_)
+                          .num_replicas(1)
+                          .set_range_partition_columns({ "key" })
+                          .Create());
+}
+
 TEST_F(ClientTest, TestMetaCacheExpiry) {
   google::FlagSaver saver;
   FLAGS_table_locations_ttl_ms = 25;

http://git-wip-us.apache.org/repos/asf/kudu/blob/7a4fafe7/src/kudu/common/partition.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/partition.cc b/src/kudu/common/partition.cc
index 5b47a36..b578831 100644
--- a/src/kudu/common/partition.cc
+++ b/src/kudu/common/partition.cc
@@ -1011,12 +1011,21 @@ namespace {
         }
         break;
       }
-      case INT64:
+      case INT64: {
+         int64_t value;
+         RETURN_NOT_OK(row->GetInt64(idx, &value));
+         if (value < INT64_MAX) {
+           RETURN_NOT_OK(row->SetInt64(idx, value + 1));
+         } else {
+           *success = false;
+         }
+         break;
+       }
       case UNIXTIME_MICROS: {
         int64_t value;
-        RETURN_NOT_OK(row->GetInt64(idx, &value));
+        RETURN_NOT_OK(row->GetUnixTimeMicros(idx, &value));
         if (value < INT64_MAX) {
-          RETURN_NOT_OK(row->SetInt64(idx, value + 1));
+          RETURN_NOT_OK(row->SetUnixTimeMicros(idx, value + 1));
         } else {
           *success = false;
         }


Mime
View raw message