CREATE SCHEMA IF NOT EXISTS S1 COMMENT 'this is a hetu schema' LOCATION '/tmp/user/mylocation';
CREATE DATABASE IF NOT EXISTS S1 LOCATION '/hive/user/warehouse/';
ALTER DATABASE db1 SET OWNER USER tester;
drop database S1;
drop schema S1 CASCADE;
CREATE TABLE tb1 (id INT, name STRING);
CREATE EXTERNAL TABLE tb1 (id INT, name STRING) LOCATION '/user/tmp';
CREATE TABLE tbl_partitioned (id INT, name STRING) PARTITIONED BY (p1 INT, p2 STRING)
COMMENT 'this is a comment' STORED AS PARQUET LOCATION '/user/tmp';
CREATE TABLE tbl_row_format (id INT, name STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY 'char';
CREATE TABLE tbl_row_format (id INT, name STRING) WITH SERDEPROPERTIES ('key'='value');
CREATE TABLE tbl_row_format (id INT, name STRING) CACHED IN 'cache_pool_name' WITH REPLICATION = 2;
CREATE TABLE tb1 (c1 TINYINT, c2 SMALLINT, c3 INT, c4 BIGINT, c5 Boolean, c6 CHAR(10), c7 VARCHAR(10),
c8 STRING, c9 DATE, c10 TIMESTAMP, c11 DECIMAL(10,3), c12 DOUBLE, c13 REAL, c14 FLOAT);
CREATE TABLE tb2 (c1 ARRAY<INT>, c2 MAP <STRING, ARRAY <STRING>>);
CREATE TABLE tb3 (c1 STRUCT <employer : STRING, id : BIGINT, address : STRING>);
CREATE TABLE tb1 AS SELECT * FROM tb2;
CREATE EXTERNAL TABLE T2 LIKE T1 COMMENT 'HETU' STORED AS AVRO LOCATION '/USER/TEST';
CREATE EXTERNAL TABLE T2 LIKE PARQUET '/user/test/impala' COMMENT 'HETU' STORED AS AVRO LOCATION '/USER/TEST';
CREATE TABLE KUDU_T3 (ID BIGINT, YEAR INT, S STRING,
                B BOOLEAN, PRIMARY KEY (ID,YEAR))
                PARTITION BY HASH (ID) PARTITIONS 20,
                RANGE (YEAR) (PARTITION 1980 <= VALUES < 1990,
                PARTITION 1990 <= VALUES < 2000,
                PARTITION VALUE = 2001,
                PARTITION 2001 < VALUES)
                STORED AS KUDU;
CREATE TABLE KUDU_T3 (PRIMARY KEY (ID,YEAR))
                PARTITION BY HASH (ID) PARTITIONS 20,
                RANGE (YEAR) (PARTITION 1980 <= VALUES < 1990,
                PARTITION 1990 <= VALUES < 2000,
                PARTITION VALUE = 2001,
                PARTITION 2001 < VALUES)
                STORED AS KUDU AS SELECT ID, YEAR, MONTH FROM T1;
SELECT * FROM tb1 WHERE c1='a' AND c2=1 AND c3>0 AND c4<10 AND c5<>0 LIMIT 100;
SELECT DISTINCT c1, c2, c3 FROM tb1 WHERE c1=1 ORDER BY c2 LIMIT 5 OFFSET 1;
SELECT COUNT(c1) AS a1 FROM tb1 GROUP BY c1 ORDER BY c1 DESC LIMIT 5;
SELECT COUNT(name) AS cnt FROM EMPLOYEE GROUP BY name HAVING MAX(salary)>110 LIMIT 5;
ALTER TABLE t1 RENAME TO t2;
ALTER TABLE t1 DROP COLUMN c1;
ALTER TABLE T1 ADD COLUMNS (N1 INT COMMENT 'NEW 1', N2 INT COMMENT 'NEW 2');
ALTER TABLE t1 REPLACE COLUMNS (n1 INT COMMENT 'NEW 1', n2 INT COMMENT 'NEW 1');
ALTER TABLE t1 ADD COLUMN IF NOT EXISTS n1 INT COMMENT 'NEW 1';
ALTER TABLE t1 SET OWNER USER test;
ALTER TABLE t1 ALTER c1 { SET BLOCK_SIZE 3};
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
DROP TABLE t1 PURGE;
CREATE VIEW v1 AS SELECT * FROM t1;
CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1;
CREATE VIEW v1 (c1, c2) AS SELECT * FROM t1;
ALTER VIEW v1 AS SELECT c1, c2 FROM t2;
ALTER VIEW v1 (n1, n2) AS SELECT c1, c2 FROM t2;
ALTER VIEW v1 RENAME TO v2;
ALTER VIEW v1 SET OWNER USER test;
DROP VIEW IF EXISTS v1;
DESCRIBE DATABASE db1;
DESCRIBE FORMATTED t1;
DESCRIBE EXTENDED t1;
DESCRIBE t1;
COMPUTE STATS st_name;
COMPUTE INCREMENTAL STATS st_name;
DROP STATS st_name;
DROP INCREMENTAL STATS ST_NAME PARTITION (PK='ABC');
CREATE FUNCTION BIGINT_TO_TIMECONV(BIGINT)
RETURNS TIMESTAMP LOCATION '/UDF/TIMECONVERTER_UDF.SO' SYMBOL='TIMECONVERTER';
CREATE FUNCTION TESTUDF
LOCATION '/USER/IMPALA/UDFS/UDF-EXAMPLES.JAR' SYMBOL='ORG.APACHE.IMPALA.TESTUDF';
REFRESH FUNCTIONS db_name;
DROP FUNCTION fn_name;
CREATE ROLE ROLE_NAME;
DROP ROLE ROLE_NAME;
GRANT ROLE role_name TO GROUP group_name;
GRANT SELECT ON TABLE table_name TO ROLE role_name WITH GRANT OPTION;
GRANT INSERT ON TABLE table_name TO ROLE role_name WITH GRANT OPTION;
GRANT ALL ON TABLE table_name TO ROLE role_name WITH GRANT OPTION;
GRANT CREATE ON TABLE table_name TO ROLE role_name WITH GRANT OPTION;
GRANT SELECT ON DATABASE db_name TO ROLE role_name WITH GRANT OPTION;
GRANT SELECT ON SERVER s_name TO ROLE role_name WITH GRANT OPTION;
REVOKE ROLE role_name FROM GROUP group_name;
REVOKE GRANT OPTION FOR SELECT ON TABLE table_name FROM ROLE role_name;
REVOKE GRANT OPTION FOR INSERT ON TABLE table_name FROM ROLE role_name;
REVOKE ALL ON TABLE table_name FROM ROLE role_name;
REVOKE CREATE ON TABLE table_name FROM ROLE role_name;
REVOKE SELECT ON DATABASE db_name FROM ROLE role_name;
SHOW TABLE STATS TEST;
SHOW COLUMN STATS TEST;
SHOW PARTITIONS TEST;
SHOW FILES IN TEST;
SHOW ROLE GRANT GROUP TEST;
SHOW GRANT ROLE R1;
SHOW GRANT USER TEST;
COMMENT ON TABLE TEST IS 'HETU';
COMMENT ON TABLE TEST IS NULL;
COMMENT ON DATABASE TEST IS NULL;
EXPLAIN SELECT * FROM T1;
SET MEM_LIMIT=10;
SET ALL;
:SHUTDOWN('LOCALHOST' : 8090, 0);
INVALIDATE METADATA TEST;
LOAD DATA INPATH '/USER/HIVE' INTO TABLE TEST PARTITION(ID=10, NAME='test');
REFRESH TEST PARTITION(ID=3, NAME='hetu');
REFRESH AUTHORIZATION;
INSERT INTO tb1 VALUES (1,1);
insert into employee (ID,NAME,AGE,ADDRESS,SALARY) VALUES (1, 'Ramesh',32, 'Ahmedabad', 20000 );
insert into employee (ID,NAME,AGE,ADDRESS,SALARY) SELECT * FROM tcopy WHERE ID>1000;
with t1 as (select * from customers where age>25) insert into t2 select * from t1;
insert /* +SHUFFLE */ into tb1 values (1,1);
insert into tb1 /* +SHUFFLE */ values (1,1);
insert into tb1 (id, name) partition (pk='v1', pk2='v2') values (1,1);
INSERT OVERWRITE tb1 VALUES (1,1);
DELETE FROM TB1 WHERE ID>1;
DELETE t1 FROM t1 JOIN t2 ON t1.x = t2.x;
DELETE T1 FROM T1 JOIN T2 ON T1.X = T2.X WHERE T1.Y = FALSE AND T2.Z > 100;
UPDATE kudu_table SET c3 = NULL WHERE c1 > 100 AND c3 IS NULL;
UPDATE T1 SET C3 = UPPER(C3) FROM K1 A1 JOIN K2 A2 ON A1.ID = A2.ID;
UPSERT INTO kudu_table (pk, c1, c2, c3) VALUES (0, 'hello', 50, true), (1, 'world', -1, false);
UPSERT INTO production_table SELECT * FROM staging_table;
UPSERT INTO production_table SELECT * FROM staging_table WHERE c1 IS NOT NULL AND c2 > 0;
SHOW SCHEMAS;
SHOW DATABASES;
SHOW SCHEMAS LIKE 't*';
Show schemas like 't*'|'a*';
Show schemas like 'hetu_1';
SHOW TABLES IN DB1;
SHOW TABLES;
SHOW TABLES FROM DB1 LIKE 't*';
SHOW TABLES FROM DB1 LIKE 't*'|'a*';
SHOW TABLES FROM DB1 LIKE 'hetu_1';
SHOW FUNCTIONS IN DB1;
SHOW AGGREGATE FUNCTIONS IN DB1;
SHOW ANALYTIC FUNCTIONS IN DB1;
SHOW CREATE TABLE TB1;
SHOW CREATE VIEW TV1;
