Anurag Mantripragada has uploaded a new patch set (#5). ( http://gerrit.cloudera.org:8080/14592 )
Change subject: IMPALA-2112: Support primary key/foreign key constraints as part of create table in Impala. ...................................................................... IMPALA-2112: Support primary key/foreign key constraints as part of create table in Impala. This is the first of several changes to use informational, unenforced primary key(pk) and foreign key(fk) specifications in Impala. The parent JIRA for this effort is IMPALA-3531. This change adds support for adding pk/fk information during create table DDLs. There is only limited SQL syntax support as of now and will add various other SQL styles including ANSI syntax support in later changes. Currently the only supported way of adding fk/pk information is after the column definitions. Examples are: CREATE TABLE pk(col1 INT, col2 STRING, PRIMARY KEY(col1, col2)); CREATE TABLE fk(id INT, col1 INT, col2 STRING, PRIMARY KEY(id), FOREIGN KEY(col1, col2) REFERENCES pk(col1, col2)); In the current implementation, manual specification of constraint names is not supported. Internally we use UUIDs for contraint name generation. Additionally, three constraint states are supported to comply with Hive's implementation which were taken from Oracle. DISABLE (default true) NOVALIDATE (default true) RELY (default true) More info here: https://docs.oracle.com/database/121/DWHSG/schemas.htm#DWHSG9053 These constraints can be optionally specified after each PK/FK specification like: CREATE TABLE pk(id INT, PRIMARY KEY(id) DISABLE, NOVALIDATE, RELY); However, a specification like this will throw an analysis errror: CREATE TABLE pk(id INT, PRIMARY KEY(id) ENABLE, VALIDATE, RELY); Notes: - Basic toSql support is added but observability changes like showing PK/FK information in DESCRIBE output will be done separately. - Retrieval of primary keys and foreign keys is currently not supported in Local Catalog Mode. Tests: Added tests to: - AnalyzeDDLTest#TestCreateTable - ParserTest#TestCreateTable - ToSqlTest#TestCreateTable - Built against both Hive-2 and Hive-3 Change-Id: Id03d8d4d41a2ac1b15e7060e2a013e334d044ee7 --- M common/thrift/CatalogObjects.thrift M common/thrift/JniCatalog.thrift M fe/src/compat-hive-2/java/org/apache/impala/compat/MetastoreShim.java M fe/src/compat-hive-3/java/org/apache/impala/compat/MetastoreShim.java M fe/src/main/cup/sql-parser.cup M fe/src/main/java/org/apache/impala/analysis/CreateTableLikeFileStmt.java M fe/src/main/java/org/apache/impala/analysis/CreateTableStmt.java M fe/src/main/java/org/apache/impala/analysis/TableDef.java M fe/src/main/java/org/apache/impala/analysis/ToSqlUtils.java M fe/src/main/java/org/apache/impala/catalog/FeFsTable.java M fe/src/main/java/org/apache/impala/catalog/HdfsTable.java M fe/src/main/java/org/apache/impala/catalog/local/LocalFsTable.java M fe/src/main/java/org/apache/impala/service/CatalogOpExecutor.java M fe/src/main/jflex/sql-scanner.flex M fe/src/test/java/org/apache/impala/analysis/AnalyzeDDLTest.java M fe/src/test/java/org/apache/impala/analysis/ParserTest.java M fe/src/test/java/org/apache/impala/analysis/ToSqlTest.java M fe/src/test/java/org/apache/impala/common/FrontendFixture.java 18 files changed, 742 insertions(+), 56 deletions(-) git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/92/14592/5 -- To view, visit http://gerrit.cloudera.org:8080/14592 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: newpatchset Gerrit-Change-Id: Id03d8d4d41a2ac1b15e7060e2a013e334d044ee7 Gerrit-Change-Number: 14592 Gerrit-PatchSet: 5 Gerrit-Owner: Anurag Mantripragada <anu...@cloudera.com> Gerrit-Reviewer: Anurag Mantripragada <anu...@cloudera.com> Gerrit-Reviewer: Impala Public Jenkins <impala-public-jenk...@cloudera.com> Gerrit-Reviewer: Quanlong Huang <huangquanl...@gmail.com> Gerrit-Reviewer: Vihang Karajgaonkar <vih...@cloudera.com>