You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kudu.apache.org by "Roger Marin (JIRA)" <ji...@apache.org> on 2017/10/05 00:25:00 UTC

[jira] [Commented] (KUDU-2168) Add support for unique constraints

    [ https://issues.apache.org/jira/browse/KUDU-2168?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16192257#comment-16192257 ] 

Roger Marin commented on KUDU-2168:
-----------------------------------

Not sure how feasible this is and I'm just getting my feet wet with the Kudu source code but I'm interested in working on this if some basic guidance is provided.

> 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:java}
> 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)