godfreyhe commented on a change in pull request #11727: [FLINK-17106][table]
Support create and drop view in Flink SQL
URL: https://github.com/apache/flink/pull/11727#discussion_r410057927
##########
File path:
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/TableEnvironmentImpl.java
##########
@@ -675,6 +677,33 @@ public void sqlUpdate(String stmt) {
UseDatabaseOperation useDatabaseOperation =
(UseDatabaseOperation) operation;
catalogManager.setCurrentCatalog(useDatabaseOperation.getCatalogName());
catalogManager.setCurrentDatabase(useDatabaseOperation.getDatabaseName());
+ } else if (operation instanceof CreateViewOperation) {
+ CreateViewOperation createViewOperation =
(CreateViewOperation) operation;
+ if (createViewOperation.isTemporary()) {
+ catalogManager.createTemporaryTable(
+ createViewOperation.getCatalogView(),
+ createViewOperation.getViewIdentifier(),
+ createViewOperation.isIgnoreIfExists());
+ } else {
+ catalogManager.createTable(
+ createViewOperation.getCatalogView(),
+ createViewOperation.getViewIdentifier(),
+ createViewOperation.isIgnoreIfExists());
+ }
+ } else if (operation instanceof DropViewOperation) {
+ DropViewOperation dropViewOperation =
(DropViewOperation) operation;
+ if (dropViewOperation.isTemporary()) {
+ boolean dropped =
catalogManager.dropTemporaryView(dropViewOperation.getViewIdentifier());
+ if (!dropped &&
!dropViewOperation.isIfExists()) {
+ throw new
ValidationException(String.format(
+ "Temporary views with
identifier %s doesn't exist",
Review comment:
Temporary views with identifier '%s' doesn't exist.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services