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

Vihang Karajgaonkar commented on IMPALA-9337:
---------------------------------------------

Hi [~krishahn] Sorry for the delay in the responding. Its been a while I worked 
on that patch and I had to test it out myself to confirm. The answer to your 
question is yes. You can change an existing external table to a synchronized 
kudu table by adding the {{external.table.purge}} property to true. See the 
following example below

 
1. Create an external kudu table with external.table.purge = true

localhost:21000] default> create external table mykudutbl (
 > id BIGINT,
 > name STRING,
 > PRIMARY KEY(id)
 > )
 > PARTITION BY HASH PARTITIONS 16
 > STORED AS KUDU
 > TBLPROPERTIES ('external.table.purge'='true');
Query: create external table mykudutbl (
id BIGINT,
 name STRING,
 PRIMARY KEY(id)
)
PARTITION BY HASH PARTITIONS 16
STORED AS KUDU
TBLPROPERTIES ('external.table.purge'='true')
+-------------------------+
| summary |
+-------------------------+
| Table has been created. |
+-------------------------+

[localhost:21000] default> show create table mykudutbl;
Query: show create table mykudutbl
+------------------------------------------------------------------------------------+
| result |
+------------------------------------------------------------------------------------+
| CREATE EXTERNAL TABLE default.mykudutbl ( |
| id BIGINT NOT NULL ENCODING AUTO_ENCODING COMPRESSION DEFAULT_COMPRESSION, |
| name STRING NULL ENCODING AUTO_ENCODING COMPRESSION DEFAULT_COMPRESSION, |
| PRIMARY KEY (id) |
| ) |
| PARTITION BY HASH (id) PARTITIONS 16 |
| STORED AS KUDU |
| TBLPROPERTIES ('external.table.purge'='true', 
'kudu.master_addresses'='localhost') |
+------------------------------------------------------------------------------------+
Fetched 1 row(s) in 0.02s

>>> Set the external.table.purge to false. The table now becomes an external 
>>> table (similar to Impala 3.3 or before)

>>> alter table mykudutbl set tblproperties('external.table.purge'='false');
Query: alter table mykudutbl set tblproperties('external.table.purge'='false')
+----------------+
| summary |
+----------------+
| Updated table. |
+----------------+
Fetched 1 row(s) in 0.28s
[localhost:21000] default> show create table mykudutbl;
Query: show create table mykudutbl
+-------------------------------------------------------------------------------------+
| result |
+-------------------------------------------------------------------------------------+
| CREATE EXTERNAL TABLE default.mykudutbl |
| STORED AS KUDU |
| TBLPROPERTIES ('external.table.purge'='false', 
'kudu.master_addresses'='localhost') |
+-------------------------------------------------------------------------------------+
Fetched 1 row(s) in 0.00s


>>> Dropping the Impala table does not drop table in Kudu

[localhost:21000] default> drop table default.mykudutbl;
Query: drop table default.mykudutbl
+-------------------------+
| summary |
+-------------------------+
| Table has been dropped. |
+-------------------------+
Fetched 1 row(s) in 0.21s

I can even create a synchronized Kudu table pointing to the Kudu table (note 
that the Kudu table name is impala::default.mykudutbl). I think that would be 
an uncommon use-case but I can do this:

>>> Create a external table pointing to a existing Kudu table.
create external table mykudtbl2
stored as kudu
tblproperties ('kudu.table_name'='impala::default.mykudutbl');
Query: create external table mykudtbl2
stored as kudu
tblproperties ('kudu.table_name'='impala::default.mykudutbl')

>>> Set the table property to external.table.purge to true. Now this table is a 
>>> synchronized external table.
alter table mykudtbl2 set TBLPROPERTIES('external.table.purge'='true');

If I drop the Impala table now, the Kudu table is dropped as well.

> Document the new way to create external Kudu tables from Impala shell
> ---------------------------------------------------------------------
>
>                 Key: IMPALA-9337
>                 URL: https://issues.apache.org/jira/browse/IMPALA-9337
>             Project: IMPALA
>          Issue Type: Documentation
>    Affects Versions: Impala 3.4.0
>            Reporter: Vihang Karajgaonkar
>            Assignee: Kris Hahn
>            Priority: Critical
>              Labels: doc
>
> IMPALA-9092 added a new way to create external Kudu tables with the purge 
> option. I think this could cause some confusion and it would be great to 
> document this option.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscr...@impala.apache.org
For additional commands, e-mail: issues-all-h...@impala.apache.org

Reply via email to