-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from HaydenOrz/test/hivesql_unit_tests
Test/hivesql unit tests
- Loading branch information
Showing
17 changed files
with
429 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import HiveSQL from '../../../../src/parser/hive'; | ||
import { readSQL } from '../../../helper'; | ||
|
||
const parser = new HiveSQL(); | ||
|
||
const features = { | ||
aborts: readSQL(__dirname, 'abort.sql'), | ||
}; | ||
|
||
describe('Hive Abort Syntax Tests', () => { | ||
features.aborts.forEach((ab) => { | ||
it(ab, () => { | ||
expect(parser.validate(ab).length).toBe(0); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import HiveSQL from '../../../../src/parser/hive'; | ||
import { readSQL } from '../../../helper'; | ||
|
||
const parser = new HiveSQL(); | ||
|
||
const features = { | ||
desc: readSQL(__dirname, 'describe.sql'), | ||
}; | ||
|
||
describe('Hive Describe Syntax Tests', () => { | ||
features.desc.forEach((des) => { | ||
it(des, () => { | ||
expect(parser.validate(des).length).toBe(0); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ABORT TRANSACTIONS 0000007 0000008 0000010 0000015; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ALTER CONNECTOR mysql_local SET DCPROPERTIES ('creator'='hayden','date'='2023-07-07'); | ||
|
||
ALTER CONNECTOR pg_local SET URL 'jdbc:postgresql://localhost:5400'; | ||
|
||
ALTER CONNECTOR hbase_local SET OWNER USER `hayden`; | ||
|
||
ALTER CONNECTOR hbase_local SET OWNER ROLE `admin`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
ALTER DATABASE mydb1 SET DBPROPERTIES ('creator'='hayden','date'='2023-07-07'); | ||
|
||
ALTER SCHEMA myschema1 SET DBPROPERTIES ('creator'='hayden','date'='2023-07-07'); | ||
|
||
ALTER DATABASE database_name SET OWNER USER hayden; | ||
|
||
ALTER SCHEMA database_name SET OWNER ROLE `admin`; | ||
|
||
ALTER DATABASE database_name SET OWNER USER jack; | ||
|
||
ALTER SCHEMA database_name SET OWNER ROLE ddladmin; | ||
|
||
ALTER DATABASE database_name SET LOCATION '/myhive/mydb'; | ||
|
||
ALTER SCHEMA database_name SET LOCATION '/myhive/myschema'; | ||
|
||
ALTER DATABASE database_name SET MANAGEDLOCATION '/myhive/myinnerdb'; | ||
|
||
ALTER SCHEMA database_name SET MANAGEDLOCATION '/myhive/myinnerschema'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ALTER SCHEDULED QUERY sq_1 EVERY HOUR AT '0:07:30'; | ||
|
||
ALTER SCHEDULED QUERY sq_2 EXECUTED AS 'user2'; | ||
|
||
ALTER SCHEDULED QUERY sq_3 DISABLED; | ||
|
||
ALTER SCHEDULED QUERY sq_4 AS SELECT * FROM tbl1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
-- Rename Table | ||
ALTER TABLE tbl1 RENAME TO tbl2; | ||
|
||
-- Alter Table Properties | ||
ALTER TABLE mydb.tb22 SET TBLPROPERTIES ('creator'='hayden'); | ||
|
||
-- Alter Table Comment | ||
ALTER TABLE mydb.tb22 SET TBLPROPERTIES ('comment' = 'This is a new comment!'); | ||
|
||
-- Add SerDe Properties | ||
ALTER TABLE employee_tb SET SERDE 'com.dt.test'; | ||
|
||
ALTER TABLE employee_tb | ||
SET SERDE 'com.dt.test' | ||
WITH SERDEPROPERTIES ('field.delim' = ','); | ||
|
||
ALTER TABLE sale_rbl | ||
PARTITION ( | ||
`pt1`='1' | ||
) | ||
SET SERDEPROPERTIES ('field.delim' = ','); | ||
|
||
-- Remove SerDe Properties | ||
ALTER TABLE sale_rbl UNSET SERDEPROPERTIES ('field.delim'); | ||
|
||
-- Alter Table Storage Properties | ||
ALTER TABLE students | ||
CLUSTERED BY (id, `name`, age) | ||
SORTED BY (age) | ||
INTO 2 BUCKETS; | ||
|
||
-- Alter Table Skewed or Stored as Directories | ||
ALTER TABLE dt_shop | ||
SKEWED BY (id, cost) | ||
ON (('id',1), ('cost', 1000)); | ||
|
||
ALTER TABLE dt_shop | ||
SKEWED BY (id, cost) | ||
ON (('id',1), ('cost', 1000)) | ||
STORED AS DIRECTORIES; | ||
|
||
-- Alter Table Not Skewed | ||
ALTER TABLE dt_shop NOT SKEWED; | ||
|
||
-- Alter Table Not Stored as Directories | ||
ALTER TABLE dt_shop NOT STORED AS DIRECTORIES; | ||
|
||
-- Alter Table Set Skewed Location | ||
ALTER TABLE dt_shop SET SKEWED LOCATION ('id'='location1', "cost"="loaction2" ); | ||
|
||
-- Alter Table Constraints | ||
ALTER TABLE tbl1 | ||
ADD CONSTRAINT const1 | ||
PRIMARY KEY (id) | ||
DISABLE NOVALIDATE; | ||
|
||
ALTER TABLE tbl2 | ||
ADD CONSTRAINT const2 | ||
FOREIGN KEY (id, `name`) | ||
REFERENCES refer_tb(rid, rname) | ||
DISABLE NOVALIDATE RELY; | ||
|
||
ALTER TABLE tbl3 | ||
ADD CONSTRAINT const3 | ||
UNIQUE (`name`, `age`) | ||
DISABLE NOVALIDATE; | ||
|
||
ALTER TABLE tbl4 | ||
CHANGE COLUMN `col1` `col2` STRING CONSTRAINT const4 | ||
NOT NULL ENABLE; | ||
|
||
ALTER TABLE tbl5 | ||
CHANGE COLUMN `col3` `col4` INT CONSTRAINT const5 | ||
DEFAULT 998 ENABLE; | ||
|
||
ALTER TABLE tbl6 | ||
CHANGE COLUMN col5 col6 MAP<STRING, STRING> CONSTRAINT const6 | ||
CHECK (1) ENABLE; | ||
|
||
ALTER TABLE tbl7 DROP CONSTRAINT remove_const; | ||
|
||
-- Alter Partition | ||
ALTER TABLE add_par_tbl | ||
ADD IF NOT EXISTS | ||
PARTITION (`pt1` = 1) LOCATION '/pat/loc' | ||
PARTITION (`pt2` = 2, `pt3`=3) LOCATION '/pat/loc' | ||
|
||
-- Rename Partition | ||
ALTER TABLE ren_par_tbl | ||
PARTITION (`pt1`=1) | ||
RENAME TO PARTITION (`pt2`=2) ; | ||
|
||
-- Exchange Partition | ||
ALTER TABLE ex_part_tbl2 | ||
EXCHANGE PARTITION (`pt1`=1) | ||
WITH TABLE ex_part_tbl1; | ||
|
||
-- Recover Partitions | ||
MSCK TABLE rec_tbl; | ||
|
||
MSCK REPAIR TABLE rec_tbl SYNC PARTITIONS; | ||
|
||
-- Drop Partitions | ||
ALTER TABLE dr_tbl1 DROP PARTITION (`pt1`=1); | ||
|
||
ALTER TABLE dr_tbl2 DROP IF EXISTS PARTITION (`pt2`=2) PURGE; | ||
|
||
-- ALTER TABLE dr_tbl2 DROP IF EXISTS PARTITION (`pt2`=2) IGNORE PROTECTION PURGE; | ||
|
||
-- Archive Partition | ||
ALTER TABLE arch_pt_tbl1 ARCHIVE PARTITION (`pt1`=1); | ||
|
||
ALTER TABLE arch_pt_tbl2 UNARCHIVE PARTITION (`pt2`=2) ; | ||
|
||
-- Add/Replace Columns | ||
ALTER TABLE rp_col_tbl1 ADD COLUMNS (`col1` INT); | ||
|
||
ALTER TABLE rp_col_tbl2 REPLACE COLUMNS (`col2` INT); | ||
|
||
ALTER TABLE rp_col_tbl2 | ||
PARTITION (`pt1`=1) | ||
ADD COLUMNS (`col3` INT COMMENT 'a new col') | ||
CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
ALTER VIEW mydb.view1 SET TBLPROPERTIES ('author'='hayden','date'='2023-07-07') | ||
|
||
ALTER VIEW view2 | ||
AS SELECT DISTINCT id, `name`, runtime | ||
FROM task_tbl | ||
WHERE type='hour'; | ||
|
||
ALTER MATERIALIZED VIEW myschema1.materialized_view_1 | ||
ENABLE REWRITE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
DESCRIBE FORMATTED default.src_table PARTITION (part_col = 100) columnA; | ||
|
||
DESCRIBE default.src_thrift lintString.$elem$.myint; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
-- Drop Database | ||
DROP SCHEMA schema1 ; | ||
|
||
DROP DATABASE IF EXISTS mydb1 RESTRICT; | ||
|
||
DROP DATABASE IF EXISTS mydb1 CASCADE; | ||
|
||
-- Drop Connector | ||
DROP CONNECTOR connector1; | ||
|
||
DROP CONNECTOR IF EXISTS connector1; | ||
|
||
-- Drop View | ||
DROP VIEW view1; | ||
|
||
DROP VIEW IF EXISTS mydb1.view2; | ||
|
||
DROP MATERIALIZED VIEW materialized_view_name; | ||
|
||
-- Drop Table | ||
DROP TABLE tb1; | ||
|
||
DROP TABLE IF EXISTS db1.tb2 PURGE; | ||
|
||
-- Drop Macro | ||
DROP TEMPORARY MACRO macro1; | ||
|
||
DROP TEMPORARY MACRO IF EXISTS macro2; | ||
|
||
-- Drop Role | ||
DROP ROLE `admin`; | ||
|
||
-- Drop Index | ||
DROP INDEX table01_index ON table01; | ||
|
||
DROP INDEX IF EXISTS table02_index ON table02; | ||
|
||
-- Drop Function | ||
DROP FUNCTION func1; | ||
|
||
DROP FUNCTION IF EXISTS func2; | ||
|
||
-- Drop Schedule Query | ||
DROP SCHEDULED QUERY sq_1; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
RELOAD FUNCTION; | ||
|
||
RELOAD FUNCTIONS; |
Oops, something went wrong.