[GitHub] [flink] zjuwangg commented on a change in pull request #10296: [FLINK-14691][table]Add use/create/drop/alter database operation and support it in flink/blink planner

2019-12-02 Thread GitBox
zjuwangg commented on a change in pull request #10296: [FLINK-14691][table]Add 
use/create/drop/alter database operation and support it in flink/blink planner
URL: https://github.com/apache/flink/pull/10296#discussion_r352993142
 
 

 ##
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalog.java
 ##
 @@ -301,10 +301,10 @@ public boolean databaseExists(String databaseName) 
throws CatalogException {
}
 
@Override
-   public void dropDatabase(String name, boolean ignoreIfNotExists) throws 
DatabaseNotExistException,
-   DatabaseNotEmptyException, CatalogException {
+   public void dropDatabase(String name, boolean ignoreIfNotExists, 
boolean restrict)
 
 Review comment:
   Yes. Addressed~


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] zjuwangg commented on a change in pull request #10296: [FLINK-14691][table]Add use/create/drop/alter database operation and support it in flink/blink planner

2019-12-02 Thread GitBox
zjuwangg commented on a change in pull request #10296: [FLINK-14691][table]Add 
use/create/drop/alter database operation and support it in flink/blink planner
URL: https://github.com/apache/flink/pull/10296#discussion_r352956870
 
 

 ##
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalog.java
 ##
 @@ -301,10 +301,10 @@ public boolean databaseExists(String databaseName) 
throws CatalogException {
}
 
@Override
-   public void dropDatabase(String name, boolean ignoreIfNotExists) throws 
DatabaseNotExistException,
-   DatabaseNotEmptyException, CatalogException {
+   public void dropDatabase(String name, boolean ignoreIfNotExists, 
boolean restrict)
 
 Review comment:
   But if so, we must call `client.dropDatabse(name, true, ignoreifNotExists, 
!cascade)`.
   The `!cascade` is not consistent with the original method.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] zjuwangg commented on a change in pull request #10296: [FLINK-14691][table]Add use/create/drop/alter database operation and support it in flink/blink planner

2019-11-24 Thread GitBox
zjuwangg commented on a change in pull request #10296: [FLINK-14691][table]Add 
use/create/drop/alter database operation and support it in flink/blink planner
URL: https://github.com/apache/flink/pull/10296#discussion_r349991863
 
 

 ##
 File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/TableEnvironmentImpl.java
 ##
 @@ -469,18 +475,57 @@ public void sqlUpdate(String stmt) {
createTableOperation.getCatalogTable(),
createTableOperation.getTableIdentifier(),
createTableOperation.isIgnoreIfExists());
+   } else if (operation instanceof CreateDatabaseOperation) {
+   CreateDatabaseOperation createDatabaseOperation = 
(CreateDatabaseOperation) operation;
+   
catalogManager.createDatabase(createDatabaseOperation.getCatalogName(),
+   
createDatabaseOperation.getDatabaseName(),
+   
createDatabaseOperation.getCatalogDatabase(),
+   
createDatabaseOperation.isIgnoreIfExists(),
+   
false);
} else if (operation instanceof DropTableOperation) {
DropTableOperation dropTableOperation = 
(DropTableOperation) operation;
catalogManager.dropTable(
dropTableOperation.getTableIdentifier(),
dropTableOperation.isIfExists());
-   } else if (operation instanceof UseCatalogOperation) {
-   UseCatalogOperation useCatalogOperation = 
(UseCatalogOperation) operation;
-   
catalogManager.setCurrentCatalog(useCatalogOperation.getCatalogName());
+   } else if (operation instanceof DropDatabaseOperation) {
+   DropDatabaseOperation dropDatabaseOperation = 
(DropDatabaseOperation) operation;
+   catalogManager.dropDatabase(
+   dropDatabaseOperation.getCatalogName(),
+   dropDatabaseOperation.getDatabaseName(),
+   dropDatabaseOperation.isIfExists(),
+   dropDatabaseOperation.isRestrict(),
+   false);
+   } else if (operation instanceof AlterDatabaseOperation) {
+   AlterDatabaseOperation alterDatabaseOperation = 
(AlterDatabaseOperation) operation;
+   catalogManager.alterDatabase(
+   alterDatabaseOperation.getCatalogName(),
+   
alterDatabaseOperation.getDatabaseName(),
+   
alterDatabaseOperation.getCatalogDatabase(),
+   false);
+   } else if (operation instanceof UseOperation) {
+   applyUseOperation((UseOperation) operation);
} else {
throw new TableException(
"Unsupported SQL query! sqlUpdate() only 
accepts a single SQL statements of " +
-   "type INSERT, CREATE TABLE, DROP TABLE, 
USE CATALOG");
+   "type INSERT, CREATE TABLE, DROP TABLE, 
USE CATALOG, USE [catalog.]database, " +
+   "CREATE DATABASE, DROP DATABASE, ALTER 
DATABASE");
 
 Review comment:
   Yes, but now we can't infer the type of unknown. We can do a refactor later.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] zjuwangg commented on a change in pull request #10296: [FLINK-14691][table]Add use/create/drop/alter database operation and support it in flink/blink planner

2019-11-24 Thread GitBox
zjuwangg commented on a change in pull request #10296: [FLINK-14691][table]Add 
use/create/drop/alter database operation and support it in flink/blink planner
URL: https://github.com/apache/flink/pull/10296#discussion_r349991483
 
 

 ##
 File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java
 ##
 @@ -455,6 +457,94 @@ public void createTable(CatalogBaseTable table, 
ObjectIdentifier objectIdentifie
"CreateTable");
}
 
+   /**
+* Creates a database in a given fully qualified path.
+* @param catalogName
+* @param databaseName
+* @param database
+* @param ignoreIfExists If false exception will be thrown if a 
database exists in the given path.
+*/
+   public void createDatabase(String catalogName,
+   String databaseName,
+   CatalogDatabase database,
+   boolean ignoreIfExists,
+   boolean ignoreNoCatalog) {
 
 Review comment:
   It provides the ability to ignore the exception if there is no corresponding 
catalog like the other catalog method behavior. I think we can keep this and so 
that it's more convenient to use later.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] zjuwangg commented on a change in pull request #10296: [FLINK-14691][table]Add use/create/drop/alter database operation and support it in flink/blink planner

2019-11-24 Thread GitBox
zjuwangg commented on a change in pull request #10296: [FLINK-14691][table]Add 
use/create/drop/alter database operation and support it in flink/blink planner
URL: https://github.com/apache/flink/pull/10296#discussion_r349987842
 
 

 ##
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveMetastoreClientWrapper.java
 ##
 @@ -149,6 +149,11 @@ public void dropDatabase(String name, boolean deleteData, 
boolean ignoreIfNotExi
client.dropDatabase(name, deleteData, ignoreIfNotExists);
}
 
+   public void dropDatabase(String name, boolean deleteData, boolean 
ignoreIfNotExists, boolean cascade)
+   throws NoSuchObjectException, 
InvalidOperationException, MetaException, TException {
+   client.dropDatabase(name, deleteData, ignoreIfNotExists, 
cascade);
 
 Review comment:
   Yes,I check it hive version's range in [1.0.0, 3.1.2], all of them support 
this method.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services