Roger Marin created KUDU-2168:
---------------------------------

             Summary: Add support for unique constraints
                 Key: KUDU-2168
                 URL: https://issues.apache.org/jira/browse/KUDU-2168
             Project: Kudu
          Issue Type: New Feature
          Components: client, master, tablet
            Reporter: Roger Marin


Kudu currently supports unique constraints via primary keys but some times a 
unique value constraint on (nullable) arbitrary column(s) independent of the 
primary key column(s) may also be required.

Example impala syntax:

{code:sql}

CREATE TABLE my_first_table
(
  id BIGINT,
  name STRING,
  unique_val_1 BIGINT,
  unique_val_2 BIGINT,
  PRIMARY KEY(id)
  UNIQUE CONSTRAINT(unique_val_1,unique_val_2)
)
PARTITION BY HASH PARTITIONS 16
STORED AS KUDU;
{code}


Example api syntax:

{code:scala}
val kuduTableSchema = StructType(
   StructField("id", IntegerType , false) ::
   StructField("name" , IntegerType, true ) ::
   StructField("unique_val_1", IntegerType , true ) ::
   StructField("unique_val_2", IntegerType , true ) :: Nil)

val kuduPrimaryKey = Seq("id")
 
val kuduTableOptions = new CreateTableOptions()
kuduTableOptions.
 setUniqueConstraintColumns(List("unique_val_1", "unique_val_2").asJava).
 setRangePartitionColumns(List("name").asJava).
 setNumReplicas(3)
 
kuduContext.createTable(kuduTableName, kuduTableSchema, kuduPrimaryKey, 
kuduTableOptions)
{code}




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to