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 2020/05/25 05:43:28 UTC

[GitHub] [flink] danny0405 opened a new pull request #12314: [FLINK-17756][table-api-java] Drop table/view shouldn't take effect o…

danny0405 opened a new pull request #12314:
URL: https://github.com/apache/flink/pull/12314


   …n each other
   
   Throws exception when we drop table with object identifier that represents a view(and vice versa).
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12314: [FLINK-17756][table-api-java] Drop table/view shouldn't take effect o…

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12314:
URL: https://github.com/apache/flink/pull/12314#issuecomment-633403476


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "b7a68f0f07ab9bb2abc3182d72c0dc80ed59dda1",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2113",
       "triggerID" : "b7a68f0f07ab9bb2abc3182d72c0dc80ed59dda1",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b7a68f0f07ab9bb2abc3182d72c0dc80ed59dda1 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2113) 
   
   <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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12314: [FLINK-17756][table-api-java] Drop table/view shouldn't take effect o…

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12314:
URL: https://github.com/apache/flink/pull/12314#issuecomment-633387995


   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 6d0fcabc96b33099fa8413428d30736c3b251fc7 (Fri Oct 16 10:56:21 UTC 2020)
   
   **Warnings:**
    * No documentation files were touched! Remember to keep the Flink docs up to date!
   
   
   <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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] JingsongLi commented on a change in pull request #12314: [FLINK-17756][table-api-java] Drop table/view shouldn't take effect o…

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #12314:
URL: https://github.com/apache/flink/pull/12314#discussion_r429745539



##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java
##########
@@ -682,20 +682,60 @@ public void alterTable(CatalogBaseTable table, ObjectIdentifier objectIdentifier
 	 * Drops a table in a given fully qualified path.
 	 *
 	 * @param objectIdentifier The fully qualified path of the table to drop.
-	 * @param ignoreIfNotExists If false exception will be thrown if the table or database or catalog to be altered
+	 * @param ignoreIfNotExists If false exception will be thrown if the table to drop
 	 *                          does not exist.
 	 */
 	public void dropTable(ObjectIdentifier objectIdentifier, boolean ignoreIfNotExists) {
-		if (temporaryTables.containsKey(objectIdentifier)) {
-			throw new ValidationException(String.format(
-				"Temporary table with identifier '%s' exists. Drop it first before removing the permanent table.",
-				objectIdentifier));
+		dropTableInternal(
+				objectIdentifier,
+				table -> table instanceof CatalogTable,
+				ignoreIfNotExists);
+	}
+
+	/**
+	 * Drops a view in a given fully qualified path.
+	 *
+	 * @param objectIdentifier The fully qualified path of the view to drop.
+	 * @param ignoreIfNotExists If false exception will be thrown if the view to drop
+	 *                          does not exist.
+	 */
+	public void dropView(ObjectIdentifier objectIdentifier, boolean ignoreIfNotExists) {
+		dropTableInternal(
+				objectIdentifier,
+				table -> table instanceof CatalogView,
+				ignoreIfNotExists);
+	}
+
+	private void dropTableInternal(
+			ObjectIdentifier objectIdentifier,
+			Predicate<CatalogBaseTable> filter,
+			boolean ignoreIfNotExists) {
+		final Optional<TableLookupResult> resultOpt = getTable(objectIdentifier);

Review comment:
       Why not just `getPermanentTable`? You can keep previous `temporaryTables.containsKey(objectIdentifier)`




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] JingsongLi merged pull request #12314: [FLINK-17756][table-api-java] Drop table/view shouldn't take effect o…

Posted by GitBox <gi...@apache.org>.
JingsongLi merged pull request #12314:
URL: https://github.com/apache/flink/pull/12314


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12314: [FLINK-17756][table-api-java] Drop table/view shouldn't take effect o…

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12314:
URL: https://github.com/apache/flink/pull/12314#issuecomment-633403476


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "b7a68f0f07ab9bb2abc3182d72c0dc80ed59dda1",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2113",
       "triggerID" : "b7a68f0f07ab9bb2abc3182d72c0dc80ed59dda1",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8180c3272155f8db184013ed79946db1571206e8",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "8180c3272155f8db184013ed79946db1571206e8",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b7a68f0f07ab9bb2abc3182d72c0dc80ed59dda1 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2113) 
   * 8180c3272155f8db184013ed79946db1571206e8 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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12314: [FLINK-17756][table-api-java] Drop table/view shouldn't take effect o…

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12314:
URL: https://github.com/apache/flink/pull/12314#issuecomment-633403476


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "b7a68f0f07ab9bb2abc3182d72c0dc80ed59dda1",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2113",
       "triggerID" : "b7a68f0f07ab9bb2abc3182d72c0dc80ed59dda1",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b7a68f0f07ab9bb2abc3182d72c0dc80ed59dda1 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2113) 
   
   <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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12314: [FLINK-17756][table-api-java] Drop table/view shouldn't take effect o…

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12314:
URL: https://github.com/apache/flink/pull/12314#issuecomment-633403476


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "b7a68f0f07ab9bb2abc3182d72c0dc80ed59dda1",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2113",
       "triggerID" : "b7a68f0f07ab9bb2abc3182d72c0dc80ed59dda1",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8180c3272155f8db184013ed79946db1571206e8",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2141",
       "triggerID" : "8180c3272155f8db184013ed79946db1571206e8",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b7a68f0f07ab9bb2abc3182d72c0dc80ed59dda1 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2113) 
   * 8180c3272155f8db184013ed79946db1571206e8 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=2141) 
   
   <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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot commented on pull request #12314: [FLINK-17756][table-api-java] Drop table/view shouldn't take effect o…

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12314:
URL: https://github.com/apache/flink/pull/12314#issuecomment-633403476


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "b7a68f0f07ab9bb2abc3182d72c0dc80ed59dda1",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "b7a68f0f07ab9bb2abc3182d72c0dc80ed59dda1",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b7a68f0f07ab9bb2abc3182d72c0dc80ed59dda1 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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot commented on pull request #12314: [FLINK-17756][table-api-java] Drop table/view shouldn't take effect o…

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12314:
URL: https://github.com/apache/flink/pull/12314#issuecomment-633387995


   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 b7a68f0f07ab9bb2abc3182d72c0dc80ed59dda1 (Mon May 25 05:45:02 UTC 2020)
   
   **Warnings:**
    * No documentation files were touched! Remember to keep the Flink docs up to date!
   
   
   <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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] JingsongLi commented on a change in pull request #12314: [FLINK-17756][table-api-java] Drop table/view shouldn't take effect o…

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #12314:
URL: https://github.com/apache/flink/pull/12314#discussion_r429745290



##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java
##########
@@ -682,20 +682,60 @@ public void alterTable(CatalogBaseTable table, ObjectIdentifier objectIdentifier
 	 * Drops a table in a given fully qualified path.
 	 *
 	 * @param objectIdentifier The fully qualified path of the table to drop.
-	 * @param ignoreIfNotExists If false exception will be thrown if the table or database or catalog to be altered
+	 * @param ignoreIfNotExists If false exception will be thrown if the table to drop
 	 *                          does not exist.
 	 */
 	public void dropTable(ObjectIdentifier objectIdentifier, boolean ignoreIfNotExists) {
-		if (temporaryTables.containsKey(objectIdentifier)) {
-			throw new ValidationException(String.format(
-				"Temporary table with identifier '%s' exists. Drop it first before removing the permanent table.",
-				objectIdentifier));
+		dropTableInternal(
+				objectIdentifier,
+				table -> table instanceof CatalogTable,
+				ignoreIfNotExists);
+	}
+
+	/**
+	 * Drops a view in a given fully qualified path.
+	 *
+	 * @param objectIdentifier The fully qualified path of the view to drop.
+	 * @param ignoreIfNotExists If false exception will be thrown if the view to drop
+	 *                          does not exist.
+	 */
+	public void dropView(ObjectIdentifier objectIdentifier, boolean ignoreIfNotExists) {
+		dropTableInternal(
+				objectIdentifier,
+				table -> table instanceof CatalogView,
+				ignoreIfNotExists);
+	}
+
+	private void dropTableInternal(
+			ObjectIdentifier objectIdentifier,
+			Predicate<CatalogBaseTable> filter,
+			boolean ignoreIfNotExists) {
+		final Optional<TableLookupResult> resultOpt = getTable(objectIdentifier);
+		if (resultOpt.isPresent()) {
+			final TableLookupResult result = resultOpt.get();
+			if (filter.test(result.getTable())) {
+				if (result.isTemporary()) {
+					// Same name temporary table or view exists.
+					throw new ValidationException(String.format(
+							"Temporary table or view with identifier '%s' exists. "
+									+ "Drop it first before removing the permanent table or view.",
+							objectIdentifier));
+				}
+			} else if (!ignoreIfNotExists) {
+				// To drop a table but the object identifier represents a view(or vise versa).
+				throw new ValidationException(String.format(
+						"Table or view with identifier '%s' does not exist.",
+						objectIdentifier.asSummaryString()));
+			} else {
+				// Table or view does not exist with ignoreIfNotExists true, do nothing.
+				return;
+			}
 		}
 		execute(

Review comment:
       Can you move this `execute` into `if (filter.test(result.getTable()))`?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12314: [FLINK-17756][table-api-java] Drop table/view shouldn't take effect o…

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12314:
URL: https://github.com/apache/flink/pull/12314#issuecomment-633403476






----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] JingsongLi commented on a change in pull request #12314: [FLINK-17756][table-api-java] Drop table/view shouldn't take effect o…

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #12314:
URL: https://github.com/apache/flink/pull/12314#discussion_r429745539



##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java
##########
@@ -682,20 +682,60 @@ public void alterTable(CatalogBaseTable table, ObjectIdentifier objectIdentifier
 	 * Drops a table in a given fully qualified path.
 	 *
 	 * @param objectIdentifier The fully qualified path of the table to drop.
-	 * @param ignoreIfNotExists If false exception will be thrown if the table or database or catalog to be altered
+	 * @param ignoreIfNotExists If false exception will be thrown if the table to drop
 	 *                          does not exist.
 	 */
 	public void dropTable(ObjectIdentifier objectIdentifier, boolean ignoreIfNotExists) {
-		if (temporaryTables.containsKey(objectIdentifier)) {
-			throw new ValidationException(String.format(
-				"Temporary table with identifier '%s' exists. Drop it first before removing the permanent table.",
-				objectIdentifier));
+		dropTableInternal(
+				objectIdentifier,
+				table -> table instanceof CatalogTable,
+				ignoreIfNotExists);
+	}
+
+	/**
+	 * Drops a view in a given fully qualified path.
+	 *
+	 * @param objectIdentifier The fully qualified path of the view to drop.
+	 * @param ignoreIfNotExists If false exception will be thrown if the view to drop
+	 *                          does not exist.
+	 */
+	public void dropView(ObjectIdentifier objectIdentifier, boolean ignoreIfNotExists) {
+		dropTableInternal(
+				objectIdentifier,
+				table -> table instanceof CatalogView,
+				ignoreIfNotExists);
+	}
+
+	private void dropTableInternal(
+			ObjectIdentifier objectIdentifier,
+			Predicate<CatalogBaseTable> filter,
+			boolean ignoreIfNotExists) {
+		final Optional<TableLookupResult> resultOpt = getTable(objectIdentifier);

Review comment:
       Why not just `getPermanentTable`?




----------------------------------------------------------------
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:
users@infra.apache.org