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 2023/01/10 13:42:56 UTC
[GitHub] [flink] LadyForest opened a new pull request, #21640: [FLINK-19883][table] Support "IF EXISTS" in DDL for ALTER TABLE
LadyForest opened a new pull request, #21640:
URL: https://github.com/apache/flink/pull/21640
## What is the purpose of the change
This pull request is a subtask of FLINK-21634 and aims to support the `ALTER TALBE IF EXISTS <table_identifier> ...` statement.
## Brief change log
- 6167b501 extends the parser template to support `IF EXISTS` and adjusts `SqlAlterTable` to add `ifExists` to the constructor params. During the operation conversion phase, `SqlToOperationConverter` will convert the alter statement to a `NopOperation` to be ignored if the table does not exist and `IF EXISTS` is specified.
## Verifying this change
This change added tests and can be verified as follows:
- FlinkSqlParserImplTest
- SqlToOperationConverterTest
- table.q
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): No
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: No
- The serializers: No
- The runtime per-record code paths (performance sensitive): No
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: No
- The S3 file system connector: No
## Documentation
- Does this pull request introduces a new feature? Yes
- If yes, how is the feature documented? It'll be documented after FLINK-22320 finishes
--
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] fsk119 commented on a diff in pull request #21640: [FLINK-19883][table] Support "IF EXISTS" in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
fsk119 commented on code in PR #21640:
URL: https://github.com/apache/flink/pull/21640#discussion_r1067731513
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/SqlToOperationConverter.java:
##########
@@ -480,6 +481,9 @@ private Operation convertAlterTable(SqlAlterTable sqlAlterTable) {
Optional<ContextResolvedTable> optionalCatalogTable =
catalogManager.getTable(tableIdentifier);
if (!optionalCatalogTable.isPresent() || optionalCatalogTable.get().isTemporary()) {
+ if (sqlAlterTable.ignoreIfNotExists()) {
+ return new NopOperation();
+ }
Review Comment:
I think we should add ignoreIfNotExists field in the `AlterTableOperation`. It's possible that the source table is dropped in execution.
##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/ddl/SqlAlterTable.java:
##########
@@ -98,6 +111,15 @@ public LinkedHashMap<String, String> getPartitionKVs() {
return SqlPartitionUtils.getPartitionKVs(getPartitionSpec());
}
+ /**
+ * Whether to ignore the error if the table doesn't exist.
+ *
+ * @return true when IF EXISTS is specified.
+ */
+ public boolean ignoreIfNotExists() {
Review Comment:
BTW, I think we should keep the code style same. In the `SqlAlterFunction`, we use `isIfExists` as method name.
--
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] fsk119 merged pull request #21640: [FLINK-19883][table] Support "IF EXISTS" in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
fsk119 merged PR #21640:
URL: https://github.com/apache/flink/pull/21640
--
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] LadyForest commented on pull request #21640: [FLINK-19883][table] Support "IF EXISTS" in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
LadyForest commented on PR #21640:
URL: https://github.com/apache/flink/pull/21640#issuecomment-1383046742
@flinkbot run azure
--
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] fsk119 commented on a diff in pull request #21640: [FLINK-19883][table] Support "IF EXISTS" in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
fsk119 commented on code in PR #21640:
URL: https://github.com/apache/flink/pull/21640#discussion_r1070212463
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ddl/AddPartitionsOperation.java:
##########
@@ -38,7 +38,7 @@ public AddPartitionsOperation(
boolean ifNotExists,
List<CatalogPartitionSpec> partitionSpecs,
List<CatalogPartition> catalogPartitions) {
- super(tableIdentifier);
+ super(tableIdentifier, false);
Review Comment:
It's a little confusing for others to understand. `AddPartitionsOperation` has `ifNotExists` and `ignoreIfNotExists` methods. Can we rename the `ignoreIfNotExists` to `ignoreIfTableNotExists` here and `ifNotExists` to `ignoreifPartitionNotExists`?
##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/ddl/SqlAlterTable.java:
##########
@@ -49,16 +49,26 @@ public abstract class SqlAlterTable extends SqlCall {
protected final SqlIdentifier tableIdentifier;
protected final SqlNodeList partitionSpec;
+ protected final boolean ifExists;
Review Comment:
I think it's better to use `ifTableExists` here
--
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] fsk119 commented on pull request #21640: [FLINK-19883][table] Support "IF EXISTS" in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
fsk119 commented on PR #21640:
URL: https://github.com/apache/flink/pull/21640#issuecomment-1383074595
@flinkbot run azure
--
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 #21640: [FLINK-19883][table] Support "IF EXISTS" in DDL for ALTER TABLE
Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #21640:
URL: https://github.com/apache/flink/pull/21640#issuecomment-1377311693
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "6167b501aa2e386dbe6f603bc51ffbd699703392",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "6167b501aa2e386dbe6f603bc51ffbd699703392",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 6167b501aa2e386dbe6f603bc51ffbd699703392 UNKNOWN
<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