You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/09/06 05:36:48 UTC
[GitHub] [flink] SteNicholas opened a new pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
SteNicholas opened a new pull request #17155:
URL: https://github.com/apache/flink/pull/17155
## What is the purpose of the change
*`ALTER TABLE` does not seem to support the `IF EXISTS` part in the DDL, but the corresponding methods `Catalog#renameTable` and `Catalog#alterTable` do support it. Flink DDL should support `IF EXISTS` in DDL for `ALTER TABLE`.*
## Brief change log
- *Add the `IF EXISTS` syntax support for the `ALTER TABLE` DDL.*
## Verifying this change
- *`SqlToOperationConverterTest`, `CatalogTableITCase` and `table.q` add the tests for `ALTER TABLE IF EXISTS` syntax.*
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (yes / **no**)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
- The serializers: (yes / **no** / don't know)
- The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / **no** / don't know)
- The S3 file system connector: (yes / **no** / don't know)
## Documentation
- Does this pull request introduce a new feature? (yes / **no**)
- If yes, how is the feature documented? (**not applicable** / docs / JavaDocs / not documented)
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17155:
URL: https://github.com/apache/flink/pull/17155#issuecomment-913385726
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23574",
"triggerID" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"triggerType" : "PUSH"
}, {
"hash" : "001d8c3dbc6d3344aa26baff0deebe3343c87318",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "001d8c3dbc6d3344aa26baff0deebe3343c87318",
"triggerType" : "PUSH"
}, {
"hash" : "34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23602",
"triggerID" : "34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 001d8c3dbc6d3344aa26baff0deebe3343c87318 UNKNOWN
* 34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23602)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17155:
URL: https://github.com/apache/flink/pull/17155#issuecomment-913385726
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23574",
"triggerID" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b63f1c5c55e45ba28e8e0b520a2f623ad94aad30 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23574)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17155:
URL: https://github.com/apache/flink/pull/17155#issuecomment-913385726
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23574",
"triggerID" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"triggerType" : "PUSH"
}, {
"hash" : "001d8c3dbc6d3344aa26baff0deebe3343c87318",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "001d8c3dbc6d3344aa26baff0deebe3343c87318",
"triggerType" : "PUSH"
}, {
"hash" : "34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23602",
"triggerID" : "34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b63f1c5c55e45ba28e8e0b520a2f623ad94aad30 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23574)
* 001d8c3dbc6d3344aa26baff0deebe3343c87318 UNKNOWN
* 34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23602)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17155:
URL: https://github.com/apache/flink/pull/17155#issuecomment-913385726
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23574",
"triggerID" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"triggerType" : "PUSH"
}, {
"hash" : "001d8c3dbc6d3344aa26baff0deebe3343c87318",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "001d8c3dbc6d3344aa26baff0deebe3343c87318",
"triggerType" : "PUSH"
}, {
"hash" : "34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23602",
"triggerID" : "34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3",
"triggerType" : "PUSH"
}, {
"hash" : "ec42d53c33d134a013c042b297a3626dfa58e277",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23737",
"triggerID" : "ec42d53c33d134a013c042b297a3626dfa58e277",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 001d8c3dbc6d3344aa26baff0deebe3343c87318 UNKNOWN
* ec42d53c33d134a013c042b297a3626dfa58e277 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23737)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] SteNicholas commented on pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
SteNicholas commented on pull request #17155:
URL: https://github.com/apache/flink/pull/17155#issuecomment-1086509438
> Thanks for your contribution @SteNicholas, Can you continue to finish this work?
@lsyldliu, thanks for the reminder. I will update this pull request this week. Sorry for the delay to update.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17155:
URL: https://github.com/apache/flink/pull/17155#issuecomment-913385726
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23574",
"triggerID" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"triggerType" : "PUSH"
}, {
"hash" : "001d8c3dbc6d3344aa26baff0deebe3343c87318",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "001d8c3dbc6d3344aa26baff0deebe3343c87318",
"triggerType" : "PUSH"
}, {
"hash" : "34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23602",
"triggerID" : "34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3",
"triggerType" : "PUSH"
}, {
"hash" : "ec42d53c33d134a013c042b297a3626dfa58e277",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "ec42d53c33d134a013c042b297a3626dfa58e277",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 001d8c3dbc6d3344aa26baff0deebe3343c87318 UNKNOWN
* 34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23602)
* ec42d53c33d134a013c042b297a3626dfa58e277 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] Airblader commented on a change in pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
Airblader commented on a change in pull request #17155:
URL: https://github.com/apache/flink/pull/17155#discussion_r703200043
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ddl/AlterTableOptionsOperation.java
##########
@@ -22,15 +22,32 @@
import org.apache.flink.table.catalog.ObjectIdentifier;
import org.apache.flink.table.operations.OperationUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
import java.util.stream.Collectors;
-/** Operation to describe a ALTER TABLE .. SET .. statement. */
+/** Operation to describe a ALTER TABLE IF EXISTS .. SET .. statement. */
public class AlterTableOptionsOperation extends AlterTableOperation {
private final CatalogTable catalogTable;
+ private final Map<String, String> tableOptions;
Review comment:
I'm still not really happy with this; now we added redundant information for the sake of the summary string, but this information isn't actually used by `CatalogManager` to alter the table.
In principle I think this class shouldn't hold a `CatalogTable` at all, but rather only an identifier (which it already does from its superclass) and the new options to be added. `TableEnvironmentImpl#executeInternal` then just looks up the table when needed (as it already does for some other operations).
Happy to hear someone else's thoughts on this as well.
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java
##########
@@ -759,14 +759,44 @@ private void dropTemporaryTableInternal(
*/
public void alterTable(
CatalogBaseTable table, ObjectIdentifier objectIdentifier, boolean ignoreIfNotExists) {
- execute(
- (catalog, path) -> {
- final CatalogBaseTable resolvedTable = resolveCatalogBaseTable(table);
- catalog.alterTable(path, resolvedTable, ignoreIfNotExists);
- },
- objectIdentifier,
- ignoreIfNotExists,
- "AlterTable");
+ alterTableInternal(table, objectIdentifier, ignoreIfNotExists, true);
+ }
+
+ /**
+ * Alters a view in a given fully qualified path.
+ *
+ * @param view The view to put in the given path
+ * @param objectIdentifier The fully qualified path where to alter the view.
+ * @param ignoreIfNotExists If false exception will be thrown if the view or database or catalog
+ * to be altered does not exist.
+ */
+ public void alterView(
+ CatalogBaseTable view, ObjectIdentifier objectIdentifier, boolean ignoreIfNotExists) {
+ alterTableInternal(view, objectIdentifier, ignoreIfNotExists, false);
+ }
+
+ public void alterTableInternal(
+ CatalogBaseTable table,
+ ObjectIdentifier objectIdentifier,
+ boolean ignoreIfNotExists,
+ boolean isAlterTable) {
Review comment:
Maybe it would be a bit nicer to pass a `TableKind kind` rather than a boolean? We could make the same change for `dropTableInternal`.
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ddl/AlterTableOptionsOperation.java
##########
@@ -22,15 +22,32 @@
import org.apache.flink.table.catalog.ObjectIdentifier;
import org.apache.flink.table.operations.OperationUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
import java.util.stream.Collectors;
-/** Operation to describe a ALTER TABLE .. SET .. statement. */
+/** Operation to describe a ALTER TABLE IF EXISTS .. SET .. statement. */
public class AlterTableOptionsOperation extends AlterTableOperation {
private final CatalogTable catalogTable;
+ private final Map<String, String> tableOptions;
Review comment:
nit: maybe call this something like `addedOptions` to make it clear that it only holds options which will be added to already existing options?
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] Airblader commented on a change in pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
Airblader commented on a change in pull request #17155:
URL: https://github.com/apache/flink/pull/17155#discussion_r702632614
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ddl/AlterTableOperation.java
##########
@@ -24,12 +24,22 @@
* Abstract Operation to describe all ALTER TABLE statements such as rename table /set properties.
*/
public abstract class AlterTableOperation implements AlterOperation {
+ protected final boolean ifExists;
Review comment:
I think we should move this below `tableIdentifier` and also change the order in the constructor to `AlterTableOperation(ObjectIdentifier, boolean)`; the table identifier is the "primary" information here.
##########
File path: flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/ddl/SqlAlterTable.java
##########
@@ -36,40 +36,61 @@
import static java.util.Objects.requireNonNull;
/**
- * Abstract class to describe statements like ALTER TABLE [[catalogName.] dataBasesName].tableName
- * ...
+ * Abstract class to describe statements like ALTER TABLE IF EXISTS [[catalogName.]
+ * dataBasesName].tableName ...
*/
public abstract class SqlAlterTable extends SqlCall {
public static final SqlSpecialOperator OPERATOR =
new SqlSpecialOperator("ALTER TABLE", SqlKind.ALTER_TABLE);
+ protected final boolean ifExists;
protected final SqlIdentifier tableIdentifier;
protected final SqlNodeList partitionSpec;
+ public SqlAlterTable(SqlParserPos pos, SqlIdentifier tableName) {
+ this(pos, false, tableName);
+ }
+
+ public SqlAlterTable(SqlParserPos pos, boolean ifExists, SqlIdentifier tableName) {
Review comment:
The order (SqlParserPos, SqlIdentifier, boolean) would feel more natural here, I think, since the table identifier is more important than the flag. The same also for the other constructor which has the boolean.
In the DDL the boolean comes first, but in the Java code I think it is more logical to have optional flags in the end.
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ddl/AlterTableOptionsOperation.java
##########
@@ -40,13 +47,18 @@ public CatalogTable getCatalogTable() {
@Override
public String asSummaryString() {
String description =
- catalogTable.getOptions().entrySet().stream()
- .map(
- entry ->
- OperationUtils.formatParameter(
- entry.getKey(), entry.getValue()))
- .collect(Collectors.joining(", "));
+ catalogTable == null
Review comment:
For `ALTER TABLE does_not_exist SET ('a' = 'b')` this will result in an incorrect summary string `ALTER TABLE does_not_exist SET ()`.
This is a bit of a design problem; the operation probably shouldn't contain a `CatalogTable`?
##########
File path: flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/ddl/SqlAlterTableAddConstraint.java
##########
@@ -43,8 +43,11 @@
* @param pos Parser position
*/
public SqlAlterTableAddConstraint(
- SqlIdentifier tableID, SqlTableConstraint constraint, SqlParserPos pos) {
- super(pos, tableID);
+ boolean ifExists,
Review comment:
Maybe change to `SqlAlterTableAddConstraint(SqlParserPos, SqlIdentifier, SqlTableConstraint, boolean)`?
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java
##########
@@ -759,14 +759,43 @@ private void dropTemporaryTableInternal(
*/
public void alterTable(
CatalogBaseTable table, ObjectIdentifier objectIdentifier, boolean ignoreIfNotExists) {
- execute(
- (catalog, path) -> {
- final CatalogBaseTable resolvedTable = resolveCatalogBaseTable(table);
- catalog.alterTable(path, resolvedTable, ignoreIfNotExists);
- },
- objectIdentifier,
- ignoreIfNotExists,
- "AlterTable");
+ alterTableInternal(table, objectIdentifier, ignoreIfNotExists, true);
+ }
+
+ /**
+ * Alters a view in a given fully qualified path.
+ *
+ * @param table The view to put in the given path
+ * @param objectIdentifier The fully qualified path where to alter the view.
+ * @param ignoreIfNotExists If false exception will be thrown if the view or database or catalog
+ * to be altered does not exist.
+ */
+ public void alterView(
+ CatalogBaseTable table, ObjectIdentifier objectIdentifier, boolean ignoreIfNotExists) {
+ alterTableInternal(table, objectIdentifier, ignoreIfNotExists, false);
+ }
+
+ public void alterTableInternal(
+ CatalogBaseTable table,
+ ObjectIdentifier objectIdentifier,
+ boolean ignoreIfNotExists,
+ boolean isDropTable) {
Review comment:
`isDropTable` doesn't fit a generic `alterTableInternal` method, this should be something like `isTable`?
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ddl/AlterTableAddConstraintOperation.java
##########
@@ -65,7 +68,9 @@ public String asSummaryString() {
params.put("columns", this.columnNames);
return OperationUtils.formatWithChildren(
- "ALTER TABLE ADD CONSTRAINT",
+ String.format(
+ "ALTER TABLE %sADD CONSTRAINT",
+ ifExists ? "IF EXISTS" + StringUtils.SPACE : StringUtils.EMPTY),
Review comment:
nit
```suggestion
ifExists ? "IF EXISTS " : StringUtils.EMPTY),
```
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ddl/AlterTableRenameOperation.java
##########
@@ -37,7 +46,9 @@ public ObjectIdentifier getNewTableIdentifier() {
@Override
public String asSummaryString() {
return String.format(
- "ALTER TABLE %s RENAME TO %s",
- tableIdentifier.asSummaryString(), newTableIdentifier.asSummaryString());
+ "ALTER TABLE %s%s RENAME TO %s",
+ ifExists ? "IF EXISTS" + StringUtils.SPACE : StringUtils.EMPTY,
Review comment:
nit
```suggestion
ifExists ? "IF EXISTS " : StringUtils.EMPTY,
```
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java
##########
@@ -759,14 +759,43 @@ private void dropTemporaryTableInternal(
*/
public void alterTable(
CatalogBaseTable table, ObjectIdentifier objectIdentifier, boolean ignoreIfNotExists) {
- execute(
- (catalog, path) -> {
- final CatalogBaseTable resolvedTable = resolveCatalogBaseTable(table);
- catalog.alterTable(path, resolvedTable, ignoreIfNotExists);
- },
- objectIdentifier,
- ignoreIfNotExists,
- "AlterTable");
+ alterTableInternal(table, objectIdentifier, ignoreIfNotExists, true);
+ }
+
+ /**
+ * Alters a view in a given fully qualified path.
+ *
+ * @param table The view to put in the given path
+ * @param objectIdentifier The fully qualified path where to alter the view.
+ * @param ignoreIfNotExists If false exception will be thrown if the view or database or catalog
+ * to be altered does not exist.
+ */
+ public void alterView(
+ CatalogBaseTable table, ObjectIdentifier objectIdentifier, boolean ignoreIfNotExists) {
+ alterTableInternal(table, objectIdentifier, ignoreIfNotExists, false);
+ }
+
+ public void alterTableInternal(
+ CatalogBaseTable table,
+ ObjectIdentifier objectIdentifier,
+ boolean ignoreIfNotExists,
+ boolean isDropTable) {
+ final Optional<CatalogBaseTable> resultOpt = getUnresolvedTable(objectIdentifier);
+ if (resultOpt.isPresent()) {
+ execute(
+ (catalog, path) -> {
+ final CatalogBaseTable resolvedTable = resolveCatalogBaseTable(table);
+ catalog.alterTable(path, resolvedTable, ignoreIfNotExists);
+ },
+ objectIdentifier,
+ ignoreIfNotExists,
+ "AlterTable");
Review comment:
Should this be `"AlterView"` in the view case?
##########
File path: flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/ddl/SqlAlterTableRename.java
##########
@@ -38,7 +38,15 @@
public SqlAlterTableRename(
SqlParserPos pos, SqlIdentifier tableName, SqlIdentifier newTableName) {
- super(pos, tableName);
+ this(pos, false, tableName, newTableName);
+ }
+
+ public SqlAlterTableRename(
+ SqlParserPos pos,
+ boolean ifExists,
Review comment:
Maybe change to `SqlAlterTableRename(SqlParserPos, SqlIdentifier, SqlIdentifier, boolean)`?
##########
File path: flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/ddl/SqlAlterTableOptions.java
##########
@@ -29,22 +29,33 @@
import static java.util.Objects.requireNonNull;
-/** ALTER TABLE [[catalogName.] dataBasesName].tableName SET ( name=value [, name=value]*). */
+/**
+ * ALTER TABLE IF EXISTS [[catalogName.] dataBasesName].tableName SET ( name=value [, name=value]*).
+ */
public class SqlAlterTableOptions extends SqlAlterTable {
private final SqlNodeList propertyList;
public SqlAlterTableOptions(
- SqlParserPos pos, SqlIdentifier tableName, SqlNodeList propertyList) {
- this(pos, tableName, null, propertyList);
+ SqlParserPos pos, boolean ifExists, SqlIdentifier tableName, SqlNodeList propertyList) {
Review comment:
Maybe change to `SqlAlterTableOptions(SqlParserPos, SqlIdentifier, SqlNodeList, boolean)`?
##########
File path: flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/ddl/SqlAlterTableReset.java
##########
@@ -33,13 +33,16 @@
import static java.util.Objects.requireNonNull;
-/** ALTER TABLE [[catalogName.] dataBasesName].tableName RESET ( 'key1' [, 'key2']*). */
+/** ALTER TABLE IF EXISTS [[catalogName.] dataBasesName].tableName RESET ( 'key1' [, 'key2']*). */
public class SqlAlterTableReset extends SqlAlterTable {
private final SqlNodeList propertyKeyList;
public SqlAlterTableReset(
- SqlParserPos pos, SqlIdentifier tableName, SqlNodeList propertyKeyList) {
- super(pos, tableName, null);
+ SqlParserPos pos,
Review comment:
Maybe change to `SqlAlterTableReset(SqlParserPos, SqlIdentifier, SqlNodeList, boolean)`?
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ddl/AlterTableDropConstraintOperation.java
##########
@@ -36,6 +38,10 @@ public String getConstraintName() {
@Override
public String asSummaryString() {
- return String.format("ALTER TABLE %s DROP CONSTRAINT %s", tableIdentifier, constraintName);
+ return String.format(
+ "ALTER TABLE %s%s DROP CONSTRAINT %s",
+ ifExists ? "IF EXISTS" + StringUtils.SPACE : StringUtils.EMPTY,
Review comment:
nit
```suggestion
ifExists ? "IF EXISTS " : StringUtils.EMPTY,
```
##########
File path: flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/SqlToOperationConverter.java
##########
@@ -385,13 +385,15 @@ private Operation convertAlterTable(SqlAlterTable sqlAlterTable) {
ObjectIdentifier tableIdentifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
Optional<CatalogManager.TableLookupResult> optionalCatalogTable =
catalogManager.getTable(tableIdentifier);
- if (!optionalCatalogTable.isPresent() || optionalCatalogTable.get().isTemporary()) {
+ if ((!sqlAlterTable.isIfExists() && !optionalCatalogTable.isPresent())
Review comment:
I think since `baseTable` is now nullable anyway, we can make this a bit simpler. What do you think?
```
final CatalogBaseTable baseTable =
optionalCatalogTable.map(CatalogManager.TableLookupResult::getTable).orElse(null);
if ((baseTable == null && !sqlAlterTable.isIfExists())
|| (baseTable != null && baseTable.isTemporary()) {
throw new ValidationException(
String.format(
"Table %s doesn't exist or is a temporary table.",
tableIdentifier.toString()));
}
```
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java
##########
@@ -759,14 +759,43 @@ private void dropTemporaryTableInternal(
*/
public void alterTable(
CatalogBaseTable table, ObjectIdentifier objectIdentifier, boolean ignoreIfNotExists) {
- execute(
- (catalog, path) -> {
- final CatalogBaseTable resolvedTable = resolveCatalogBaseTable(table);
- catalog.alterTable(path, resolvedTable, ignoreIfNotExists);
- },
- objectIdentifier,
- ignoreIfNotExists,
- "AlterTable");
+ alterTableInternal(table, objectIdentifier, ignoreIfNotExists, true);
+ }
+
+ /**
+ * Alters a view in a given fully qualified path.
+ *
+ * @param table The view to put in the given path
Review comment:
The argument should probably be called `view` rather than `table` now?
##########
File path: flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/ddl/SqlAlterTableDropConstraint.java
##########
@@ -38,8 +38,11 @@
* @param pos Parser position
*/
public SqlAlterTableDropConstraint(
- SqlIdentifier tableID, SqlIdentifier constraintName, SqlParserPos pos) {
- super(pos, tableID);
+ boolean ifExists,
Review comment:
Maybe change to `SqlAlterTableDropConstraint(SqlParserPos, SqlIdentifier, SqlIdentifier, boolean)`?
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ddl/AlterTableOptionsOperation.java
##########
@@ -22,14 +22,21 @@
import org.apache.flink.table.catalog.ObjectIdentifier;
import org.apache.flink.table.operations.OperationUtils;
+import org.apache.commons.lang3.StringUtils;
+
import java.util.stream.Collectors;
-/** Operation to describe a ALTER TABLE .. SET .. statement. */
+/** Operation to describe a ALTER TABLE IF EXISTS .. SET .. statement. */
public class AlterTableOptionsOperation extends AlterTableOperation {
private final CatalogTable catalogTable;
public AlterTableOptionsOperation(ObjectIdentifier tableIdentifier, CatalogTable catalogTable) {
- super(tableIdentifier);
+ this(false, tableIdentifier, catalogTable);
+ }
+
+ public AlterTableOptionsOperation(
Review comment:
`AlterTableOptionsOperation(ObjectIdentifier, CatalogTable, boolean)`?
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ddl/AlterTableDropConstraintOperation.java
##########
@@ -20,13 +20,15 @@
import org.apache.flink.table.catalog.ObjectIdentifier;
-/** Operation of "ALTER TABLE ADD [CONSTRAINT constraintName] ..." clause. * */
+import org.apache.commons.lang3.StringUtils;
+
+/** Operation of "ALTER TABLE IF EXISTS ADD [CONSTRAINT constraintName] ..." clause. * */
public class AlterTableDropConstraintOperation extends AlterTableOperation {
private final String constraintName;
public AlterTableDropConstraintOperation(
- ObjectIdentifier tableIdentifier, String constraintName) {
- super(tableIdentifier);
+ boolean ifExists, ObjectIdentifier tableIdentifier, String constraintName) {
Review comment:
Maybe change this to `AlterTableDropConstraintOperation(ObjectIdentifier, String, boolean)`?
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ddl/AlterTableRenameOperation.java
##########
@@ -20,13 +20,22 @@
import org.apache.flink.table.catalog.ObjectIdentifier;
-/** Operation to describe a ALTER TABLE .. RENAME to .. statement. */
+import org.apache.commons.lang3.StringUtils;
+
+/** Operation to describe a ALTER TABLE IF EXISTS .. RENAME to .. statement. */
public class AlterTableRenameOperation extends AlterTableOperation {
private final ObjectIdentifier newTableIdentifier;
public AlterTableRenameOperation(
ObjectIdentifier tableIdentifier, ObjectIdentifier newTableIdentifier) {
- super(tableIdentifier);
+ this(false, tableIdentifier, newTableIdentifier);
+ }
+
+ public AlterTableRenameOperation(
Review comment:
`AlterTableRenameOperation(ObjectIdentifier, ObjectIdentifier, boolean)`?
##########
File path: flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/catalog/CatalogTableITCase.scala
##########
@@ -995,6 +995,56 @@ class CatalogTableITCase(isStreamingMode: Boolean) extends AbstractTestBase {
assertEquals(false, tableSchema2.getPrimaryKey.isPresent)
}
+ @Test
+ def testAlterTableWithIfExists(): Unit = {
Review comment:
I think a whole separate IT case for this isn't necessary, this is really quite heavy on the test performance.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17155:
URL: https://github.com/apache/flink/pull/17155#issuecomment-913385726
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23574",
"triggerID" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"triggerType" : "PUSH"
}, {
"hash" : "001d8c3dbc6d3344aa26baff0deebe3343c87318",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "001d8c3dbc6d3344aa26baff0deebe3343c87318",
"triggerType" : "PUSH"
}, {
"hash" : "34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23602",
"triggerID" : "34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3",
"triggerType" : "PUSH"
}, {
"hash" : "ec42d53c33d134a013c042b297a3626dfa58e277",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23737",
"triggerID" : "ec42d53c33d134a013c042b297a3626dfa58e277",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 001d8c3dbc6d3344aa26baff0deebe3343c87318 UNKNOWN
* 34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23602)
* ec42d53c33d134a013c042b297a3626dfa58e277 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23737)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17155:
URL: https://github.com/apache/flink/pull/17155#issuecomment-913385726
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23574",
"triggerID" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"triggerType" : "PUSH"
}, {
"hash" : "34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23602",
"triggerID" : "34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3",
"triggerType" : "PUSH"
}, {
"hash" : "ec42d53c33d134a013c042b297a3626dfa58e277",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23737",
"triggerID" : "ec42d53c33d134a013c042b297a3626dfa58e277",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* ec42d53c33d134a013c042b297a3626dfa58e277 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23737)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17155:
URL: https://github.com/apache/flink/pull/17155#issuecomment-913385726
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23574",
"triggerID" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"triggerType" : "PUSH"
}, {
"hash" : "001d8c3dbc6d3344aa26baff0deebe3343c87318",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "001d8c3dbc6d3344aa26baff0deebe3343c87318",
"triggerType" : "PUSH"
}, {
"hash" : "34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b63f1c5c55e45ba28e8e0b520a2f623ad94aad30 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23574)
* 001d8c3dbc6d3344aa26baff0deebe3343c87318 UNKNOWN
* 34424f3a53dcfd09dfaa0b0ecb30b86d3f3b75d3 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] SteNicholas commented on a change in pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
SteNicholas commented on a change in pull request #17155:
URL: https://github.com/apache/flink/pull/17155#discussion_r704049843
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ddl/AlterTableOptionsOperation.java
##########
@@ -22,15 +22,32 @@
import org.apache.flink.table.catalog.ObjectIdentifier;
import org.apache.flink.table.operations.OperationUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
import java.util.stream.Collectors;
-/** Operation to describe a ALTER TABLE .. SET .. statement. */
+/** Operation to describe a ALTER TABLE IF EXISTS .. SET .. statement. */
public class AlterTableOptionsOperation extends AlterTableOperation {
private final CatalogTable catalogTable;
+ private final Map<String, String> tableOptions;
Review comment:
@Airblader , the `CatalogTable` isn't hold only by `AlterTableOptionsOperation`. Other operations like `AlterTableSchemaOperation` also hold the `CatalogTable`.
IMO, the converter between the SQL and operation should not pass the `CatalogTable`. The `CatalogTable` is looked up when calling `TableEnvironmentImpl#executeInternal`. But the changes could be pushed another PR to unify updating.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #17155:
URL: https://github.com/apache/flink/pull/17155#issuecomment-913385726
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b63f1c5c55e45ba28e8e0b520a2f623ad94aad30 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #17155:
URL: https://github.com/apache/flink/pull/17155#issuecomment-913359400
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.
## Automated Checks
Last check on commit a89b8c4b0fd8bc06f2a771abc5cdcde023b51df4 (Mon Sep 06 05:43:28 UTC 2021)
**Warnings:**
* No documentation files were touched! Remember to keep the Flink docs up to date!
* **This pull request references an unassigned [Jira ticket](https://issues.apache.org/jira/browse/FLINK-19883).** According to the [code contribution guide](https://flink.apache.org/contributing/contribute-code.html), tickets need to be assigned before starting with the implementation work.
<sub>Mention the bot in a comment to re-run the automated checks.</sub>
## Review Progress
* ❓ 1. The [description] looks good.
* ❓ 2. There is [consensus] that the contribution should go into to Flink.
* ❓ 3. Needs [attention] from.
* ❓ 4. The change fits into the overall [architecture].
* ❓ 5. Overall code [quality] is good.
Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
- `@flinkbot approve all` to approve all aspects
- `@flinkbot approve-until architecture` to approve everything until `architecture`
- `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
- `@flinkbot disapprove architecture` to remove an approval you gave earlier
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] Airblader commented on a change in pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
Airblader commented on a change in pull request #17155:
URL: https://github.com/apache/flink/pull/17155#discussion_r704055469
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ddl/AlterTableOptionsOperation.java
##########
@@ -22,15 +22,32 @@
import org.apache.flink.table.catalog.ObjectIdentifier;
import org.apache.flink.table.operations.OperationUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
import java.util.stream.Collectors;
-/** Operation to describe a ALTER TABLE .. SET .. statement. */
+/** Operation to describe a ALTER TABLE IF EXISTS .. SET .. statement. */
public class AlterTableOptionsOperation extends AlterTableOperation {
private final CatalogTable catalogTable;
+ private final Map<String, String> tableOptions;
Review comment:
Yes, other operations do that, too, and probably shouldn't do it either. The design of operations needs to be improved overall, because both the operations and the converter contain way too much logic. I think it would be good to improve this for this operation with this PR, because we kind of need it. Otherwise we'd have either incorrectness or redundancy, and both would be a worse situation than before.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17155:
URL: https://github.com/apache/flink/pull/17155#issuecomment-913385726
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23574",
"triggerID" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"triggerType" : "PUSH"
}, {
"hash" : "001d8c3dbc6d3344aa26baff0deebe3343c87318",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "001d8c3dbc6d3344aa26baff0deebe3343c87318",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b63f1c5c55e45ba28e8e0b520a2f623ad94aad30 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23574)
* 001d8c3dbc6d3344aa26baff0deebe3343c87318 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] Airblader commented on a change in pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
Airblader commented on a change in pull request #17155:
URL: https://github.com/apache/flink/pull/17155#discussion_r704055469
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ddl/AlterTableOptionsOperation.java
##########
@@ -22,15 +22,32 @@
import org.apache.flink.table.catalog.ObjectIdentifier;
import org.apache.flink.table.operations.OperationUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
import java.util.stream.Collectors;
-/** Operation to describe a ALTER TABLE .. SET .. statement. */
+/** Operation to describe a ALTER TABLE IF EXISTS .. SET .. statement. */
public class AlterTableOptionsOperation extends AlterTableOperation {
private final CatalogTable catalogTable;
+ private final Map<String, String> tableOptions;
Review comment:
Yes, other operations do that, too, and probably shouldn't do it either. The design of operations needs to be improved overall, because both the operations and the converter contain way too much logic. I think it would be good to improve this for this operation with this PR, because we kind of need it. Otherwise we'd have either incorrectness or redundancy, and both would be a worse situation than before.
I don't think it's a big change to fix this here. It's a pretty small change to just look up the table in `TableEnvironmentImpl` instead of passing it to the operation during the conversion.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] SteNicholas commented on a change in pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
SteNicholas commented on a change in pull request #17155:
URL: https://github.com/apache/flink/pull/17155#discussion_r704049843
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ddl/AlterTableOptionsOperation.java
##########
@@ -22,15 +22,32 @@
import org.apache.flink.table.catalog.ObjectIdentifier;
import org.apache.flink.table.operations.OperationUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
import java.util.stream.Collectors;
-/** Operation to describe a ALTER TABLE .. SET .. statement. */
+/** Operation to describe a ALTER TABLE IF EXISTS .. SET .. statement. */
public class AlterTableOptionsOperation extends AlterTableOperation {
private final CatalogTable catalogTable;
+ private final Map<String, String> tableOptions;
Review comment:
@Airblader , the `CatalogTable` isn't hold only by `AlterTableOptionsOperation`. Other operations like `AlterTableSchemaOperation` also hold the `CatalogTable`.
IMO, the converter between the SQL and operation should not pass the `CatalogTable`. The `CatalogTable` is looked up when calling `TableEnvironmentImpl#executeInternal`. But the changes could be pushed another PR to unify for updating.
cc @wuchong
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] SteNicholas commented on pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
SteNicholas commented on pull request #17155:
URL: https://github.com/apache/flink/pull/17155#issuecomment-913990898
@wuchong @Airblader , I have addressed the comments mentioned above. Please help to review again.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] SteNicholas removed a comment on pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
SteNicholas removed a comment on pull request #17155:
URL: https://github.com/apache/flink/pull/17155#issuecomment-914920602
@Airblader , I have addressed the minor comments above and left a reply for the `CatalogTable` holding. Please take a look.
@wuchong , do you have any comments?
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17155:
URL: https://github.com/apache/flink/pull/17155#issuecomment-913385726
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23574",
"triggerID" : "b63f1c5c55e45ba28e8e0b520a2f623ad94aad30",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b63f1c5c55e45ba28e8e0b520a2f623ad94aad30 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23574)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] SteNicholas commented on pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
SteNicholas commented on pull request #17155:
URL: https://github.com/apache/flink/pull/17155#issuecomment-914920602
@Airblader , I have addressed the minor comments above and left a reply for the `CatalogTable` holding. Please take a look.
@wuchong , do you have any comments?
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] SteNicholas commented on a change in pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
SteNicholas commented on a change in pull request #17155:
URL: https://github.com/apache/flink/pull/17155#discussion_r704062837
##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ddl/AlterTableOptionsOperation.java
##########
@@ -22,15 +22,32 @@
import org.apache.flink.table.catalog.ObjectIdentifier;
import org.apache.flink.table.operations.OperationUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
import java.util.stream.Collectors;
-/** Operation to describe a ALTER TABLE .. SET .. statement. */
+/** Operation to describe a ALTER TABLE IF EXISTS .. SET .. statement. */
public class AlterTableOptionsOperation extends AlterTableOperation {
private final CatalogTable catalogTable;
+ private final Map<String, String> tableOptions;
Review comment:
@Airblader , OK, I would like to change for this.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] lsyldliu commented on pull request #17155: [FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
lsyldliu commented on pull request #17155:
URL: https://github.com/apache/flink/pull/17155#issuecomment-1086498370
Thanks for your contribution @SteNicholas, Can you continue to finish this work?
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org