You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by to...@apache.org on 2017/01/30 23:58:30 UTC

[2/3] kudu git commit: KUDU-1831. Java client does not check if the primary key columns are specified first

KUDU-1831. Java client does not check if the primary key columns
are specified first

This commit cleans up the java doc in Schema class, add some info
to the java doc in AsyncKuduClient class, and add a test to cover
the out of order primary key case.

Change-Id: I1ca2a572801c964331ed65c630db28436fcaf86a
Reviewed-on: http://gerrit.cloudera.org:8080/5723
Tested-by: Kudu Jenkins
Reviewed-by: Jean-Daniel Cryans <jd...@apache.org>


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

Branch: refs/heads/master
Commit: d2c823c9db64a4ca7ac07501b3ff9ce0488794ad
Parents: ce04fe5
Author: Jun He <ju...@gmail.com>
Authored: Sat Jan 14 23:12:03 2017 -0800
Committer: Jean-Daniel Cryans <jd...@apache.org>
Committed: Fri Jan 27 16:28:05 2017 +0000

----------------------------------------------------------------------
 .../src/main/java/org/apache/kudu/Schema.java   |  3 +--
 .../org/apache/kudu/client/AsyncKuduClient.java |  3 +++
 .../apache/kudu/client/TestAsyncKuduClient.java | 26 ++++++++++++++++++++
 3 files changed, 30 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/d2c823c9/java/kudu-client/src/main/java/org/apache/kudu/Schema.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/Schema.java b/java/kudu-client/src/main/java/org/apache/kudu/Schema.java
index d9eae40..dd7695f 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/Schema.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/Schema.java
@@ -68,8 +68,8 @@ public class Schema {
 
   /**
    * Constructs a schema using the specified columns and does some internal accounting
+   *
    * @param columns the columns in index order
-   * @throws IllegalArgumentException If the key columns aren't specified first
    *
    * See {@code ColumnPBsToSchema()} in {@code src/kudu/common/wire_protocol.cc}
    */
@@ -84,7 +84,6 @@ public class Schema {
    *
    * @param columns the columns in index order
    * @param columnIds the column ids of the provided columns, or null
-   * @throws IllegalArgumentException If the primary key columns aren't specified first
    * @throws IllegalArgumentException If the column ids length does not match the columns length
    *
    * See {@code ColumnPBsToSchema()} in {@code src/kudu/common/wire_protocol.cc}

http://git-wip-us.apache.org/repos/asf/kudu/blob/d2c823c9/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
index fb478f9..91f03ff 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
@@ -246,6 +246,9 @@ public class AsyncKuduClient implements AutoCloseable {
 
   /**
    * Create a table on the cluster with the specified name, schema, and table configurations.
+   * If the primary key columns of the table schema aren't specified first, the deferred result
+   * will be a {@link NonRecoverableException}
+   *
    * @param name the table's name
    * @param schema the table's schema
    * @param builder a builder containing the table's configurations

http://git-wip-us.apache.org/repos/asf/kudu/blob/d2c823c9/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java
index 3502909..16522d3 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java
@@ -34,9 +34,12 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.kudu.ColumnSchema;
 import org.apache.kudu.Common;
 import org.apache.kudu.consensus.Metadata;
 import org.apache.kudu.master.Master;
+import org.apache.kudu.Schema;
+import org.apache.kudu.Type;
 
 public class TestAsyncKuduClient extends BaseKuduTest {
   private static final Logger LOG = LoggerFactory.getLogger(TestAsyncKuduClient.class);
@@ -227,4 +230,27 @@ public class TestAsyncKuduClient extends BaseKuduTest {
     assertTrue(response.hasRowError());
     assertTrue(response.getRowError().getErrorStatus().isTimedOut());
   }
+
+
+  /**
+   * Test creating a table with out of order primary keys in the table schema .
+   */
+  @Test(timeout = 100000)
+  public void testCreateTableOutOfOrderPrimaryKeys() throws Exception {
+    ArrayList<ColumnSchema> columns = new ArrayList<ColumnSchema>(6);
+    columns.add(new ColumnSchema.ColumnSchemaBuilder("key_1", Type.INT8).key(true).build());
+    columns.add(new ColumnSchema.ColumnSchemaBuilder("column1_i", Type.INT32).build());
+    columns.add(new ColumnSchema.ColumnSchemaBuilder("key_2", Type.INT16).key(true).build());
+    columns.add(new ColumnSchema.ColumnSchemaBuilder("column2_i", Type.INT32).build());
+    columns.add(new ColumnSchema.ColumnSchemaBuilder("column3_s", Type.STRING).build());
+    columns.add(new ColumnSchema.ColumnSchemaBuilder("column4_b", Type.BOOL).build());
+    Schema schema = new Schema(columns);
+    try {
+      client.createTable("testCreateTableOutOfOrderPrimaryKeys-" + System.currentTimeMillis(),
+          schema,
+          getBasicCreateTableOptions()).join();
+    } catch (NonRecoverableException nre) {
+      assertTrue(nre.getMessage().startsWith("Got out-of-order key column"));
+    }
+  }
 }