Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

We propose to add the following DDLs related to catalog operations.

  • createCatalogStatement:

CREATE CATALOG [ IF NOT EXISTS ] catalogName
[WITH ( name=value [, name=value]*)]

IF NOT EXISTS:

If a catalog with the same name already exists, nothing will happen.

  • showCatalogsStatement

SHOW CATALOGS


Return all catalogs in the current catalog.

note: already support in sql client but need support in TableEnvironment.

  • describeCatalogStatement

DESCRIBE CATALOG catalogName

Return the default database name and expalnCatalog(newly added method in the catalog) content of an existing catalogName 

Newly added method in Catalog.java:

/**
* Get a user defined catalog description.
* @return a user-implement catalog detailed explanation
*/
default String explainCatalog() {
    return String.format("CatalogClass:%s", this.getClass().getCanonicalName());
}

use eg:

Flink SQL> describe catalog hiveCatalog;
default database: default.
hiveVersion: 2.3.4
...


  • useCatalogStatement

USE CATALOG catalogName 

Set the current catalog. 

...

We propose to add the following DDLs related to database operations.

  • createDatabaseStatement:

CREATE  DATABASE [ IF NOT EXISTS ] [ catalogName.] dataBaseName
[ COMMENT database_comment ]
[WITH ( name=value [, name=value]*)]

IF NOT EXISTS:

If a database with the same name already exists, nothing will happen.

  • dropDatabaseStatement:

DROP  DATABASE [ IF EXISTS ] [ catalogName.] dataBaseName
[ (RESTRICT|CASCADE)]

IF EXISTS

If the database to drop does not exist, nothing happens.

...

Catalog.dropDatabase method should add new cascade flag

/**
* Drop a database.
*
* @param name              Name of the database to be dropped.
* @param ignoreIfNotExists Flag to specify behavior when the database does not exist:
*                          if set to false, throw an exception,
*                          if set to true, do nothing.

* @param cascade Flag to specify behavior when the database is not empty
*                          if set to false, throw an exception,
*                          if set to true, delete all related tables and functions.
* @throws DatabaseNotExistException if the given database does not exist
* @throws CatalogException in case of any runtime exception
*/
void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade) throws DatabaseNotExistException,
  DatabaseNotEmptyException, CatalogException;


  • alterDatabaseStatement:

ALTER  DATABASE  [ catalogName.] dataBaseName SET

DBPROPERTIES

 PROPERTIES
( name=value [, name=value]*)


Set one or more properties in the specified database. If a particular property is already set in the database, override the old value with the new one.

  • useDatabaseStatement:

USE [ catalogName.] dataBaseName 

Set the current database. All subsequent commands that do not explicitly specify a database will use this one. If the provided database does not exist, an exception is thrown.

note: already support in sql client but need support in tEnv.sqlQuery();

  • showDatabasesStatement:

SHOW DATABASES

Return all databases in the current catalog.

note: already support in sql client but need support in tEnv.sqlQuery();

  • descDatabaseStatement:

DESCRIBE  DATABASE [ EXTENDED] [ catalogName.] dataBasesName 

Return the metadata of an existing database (name, comment, description). 

...

Return the metadata of an existing database (name, comment, description, properties and detailed description). 

use eg:

FLINK SQL> describe database hive.default;
database name: default
comment: hive default database
description: created by terry to verify function
FLINK SQL > describe database extended hive.default;
database name: default
comment: hive default database
description: created by terry to verify function
properties:
create-time: 2019-09-26 10:00:00
detailed description: ....

Table DDL:


We propose to add the following DDLs related to table operations.

  • showTablesStatement:

SHOW TABLES

Return all tables in the current database.

note: already support in sql client but need support in TableEnvironment.

  • descTableStatement:

DESCRIBE [ EXTENDED]  [[catalogName.] dataBasesName].tableName


Return the metadata of an existing table (column names, data types, and comments). 

...

note: already support in sql client but need support in TableEnvironment.

  • alterTableStatement:

ALTER TABLE  [[catalogName.] dataBasesName].tableName
REAME TO newTableName


Rename an existing table.

ALTER TABLE  [[catalogName.] dataBasesName].tableName
SET  PROPERTIES ( name=value [, name=value]*)


Set the properties of an existing table 

...