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

Wenzhe Zhou commented on IMPALA-11906:
--------------------------------------

Samples with non unique primary keys:

{code:java}
[localhost:21050] default>  CREATE TABLE kudu_tbl1 (id INT NON UNIQUE PRIMARY 
KEY, name STRING) PARTITION BY HASH (id) PARTITIONS 3 STORED as KUDU;
Query: CREATE TABLE kudu_tbl1 (id INT NON UNIQUE PRIMARY KEY, name STRING) 
PARTITION BY HASH (id) PARTITIONS 3 STORED as KUDU
+-------------------------+
| summary                 |
+-------------------------+
| Table has been created. |
+-------------------------+
Fetched 1 row(s) in 4.79s
[localhost:21050] default> desc kudu_tbl1;
Query: describe kudu_tbl1
+----------------------+--------+---------+-------------+------------+----------+---------------+---------------+---------------------+------------+
| name                 | type   | comment | primary_key | key_unique | nullable 
| default_value | encoding      | compression         | block_size |
+----------------------+--------+---------+-------------+------------+----------+---------------+---------------+---------------------+------------+
| id                   | int    |         | true        | false      | false    
|               | AUTO_ENCODING | DEFAULT_COMPRESSION | 0          |
| auto_incrementing_id | bigint |         | true        | false      | false    
|               | AUTO_ENCODING | DEFAULT_COMPRESSION | 0          |
| name                 | string |         | false       |            | true     
|               | AUTO_ENCODING | DEFAULT_COMPRESSION | 0          |
+----------------------+--------+---------+-------------+------------+----------+---------------+---------------+---------------------+------------+
Fetched 3 row(s) in 4.72s
[localhost:21050] default> 

{code}


> Impala Doc: Support non unique primary key for Kudu table
> ---------------------------------------------------------
>
>                 Key: IMPALA-11906
>                 URL: https://issues.apache.org/jira/browse/IMPALA-11906
>             Project: IMPALA
>          Issue Type: Documentation
>          Components: Docs
>    Affects Versions: Impala 4.3.0
>            Reporter: Wenzhe Zhou
>            Assignee: shajini thayasingh
>            Priority: Major
>              Labels: documentation
>
> IMPALA-11809 Added support non unique primary key for Kudu table. We should 
> document the syntax for non unique primary key.
> - We added syntactic support for creating Kudu table with non unique primary 
> key.
>   For example: 
>     CREATE TABLE tbl (id INT NON UNIQUE PRIMARY KEY, name STRING)
>     PARTITION BY HASH (id) PARTITIONS 3
>     STORED as KUDU;
>   More samples could be found in the commit messages of 
> https://issues.apache.org/jira/browse/IMPALA-11809
> - Kudu engine appends a system generated auto-incrementing column to the non 
> unique primary key columns to guarantee the uniqueness on primary key. This 
> auto-incrementing column is named as 'auto_incrementing_id' with bigint type. 
> The assignment to it during insertion is automatic.
> 'auto_incrementing_id' column cannot be added, removed or renamed with ALTER 
> TABLE statements.
> - When creating a Kudu table, specifying PRIMARY KEY is optional now. If 
> there is no primary key attribute specified, the partition key columns could 
> be promoted as non unique primary key if those columns are the beginning 
> columns of the table.
> In following sample, 'a' and 'b' will be promoted as non unique primary key, 
> 'auto_incrementing_id' column will be added by Kudu engine.  'a', 'b' and 
> 'auto_incrementing_id' form the effective unique composite primary key.
>     CREATE TABLE tbl (a INT, b STRING, c FLOAT)
>      PARTITION BY HASH (a, b) PARTITIONS 3
>      STORED as KUDU;
> - New column "key_unique" is added to the output of 'describe' table command 
> for Kudu table, which shows if the primary key is unique.
> -  SELECT statement does not show the system generated auto-incrementing 
> column unless the column is explicitly specified in the select list.
> - UPSERT operation is not supported for Kudu tables with non unique primary 
> key.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to