[
https://issues.apache.org/jira/browse/KUDU-2168?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16192260#comment-16192260
]
Todd Lipcon commented on KUDU-2168:
-----------------------------------
I think this would be very very difficult to implement. Unique constraints are
typically implemented using a secondary index, so this task would boil down to
first adding indexes and then adding constraint-checking based on the index at
write time. Additionally, the indexes would have to be global (i.e
cross-partition) assuming that the unique constraint may be applied to any
columns, which means that we'd need to implement multi-partition read-write
transactions before we could implement the indexing.
All in, I think this would probably be a couple of person-years worth of full
time effort, so not a great starter project to get your feet wet. If you're
interested in contributing in other smaller changes first you can search for
the 'newbie' label in JIRA or email the dev mailing list for some suggested
first patches.
> 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)