Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-4288

Make it possible to unregister tables

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3.0
    • Component/s: Table API & SQL
    • Labels:
      None

      Description

      Table names can not be changed yet. After registration you can not modify the table behind a table name. Maybe this behavior is too restrictive.

        Issue Links

          Activity

          Hide
          jark Jark Wu added a comment -

          Because SchemaPlus has no remove function, we can't unregister tables easily. Do you have any ideas to do this ?

          Show
          jark Jark Wu added a comment - Because SchemaPlus has no remove function, we can't unregister tables easily. Do you have any ideas to do this ?
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user twalthr opened a pull request:

          https://github.com/apache/flink/pull/2511

          FLINK-4288 [table] Make it possible to unregister tables

          Thanks for contributing to Apache Flink. Before you open your pull request, please take the following check list into consideration.
          If your changes take all of the items into account, feel free to open your pull request. For more information and/or questions please refer to the [How To Contribute guide](http://flink.apache.org/how-to-contribute.html).
          In addition to going through the list, please provide a meaningful description of your changes.

          • [x] General
          • The pull request references the related JIRA issue ("[FLINK-XXX] Jira title text")
          • The pull request addresses only one issue
          • Each commit in the PR has a meaningful commit message (including the JIRA id)
          • [ ] Documentation
          • Documentation has been added for new functionality
          • Old documentation affected by the pull request has been updated
          • JavaDoc for public methods has been added
          • [x] Tests & Build
          • Functionality added by the pull request is covered by tests
          • `mvn clean verify` has been executed successfully locally or a Travis build has passed

          This PR adds the possibility to unregister tables. Although Calcite supports mutable schemas, deleting a table instead of replacing it was not easy to implement. I will add some documentation if you are fine with this PR.

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/twalthr/flink FLINK-4288

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/flink/pull/2511.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #2511


          commit 0ecb6138680498bdacb134eff1609b21cbb07cd9
          Author: twalthr <twalthr@apache.org>
          Date: 2016-09-19T12:09:14Z

          FLINK-4288 [table] Make it possible to unregister tables


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user twalthr opened a pull request: https://github.com/apache/flink/pull/2511 FLINK-4288 [table] Make it possible to unregister tables Thanks for contributing to Apache Flink. Before you open your pull request, please take the following check list into consideration. If your changes take all of the items into account, feel free to open your pull request. For more information and/or questions please refer to the [How To Contribute guide] ( http://flink.apache.org/how-to-contribute.html ). In addition to going through the list, please provide a meaningful description of your changes. [x] General The pull request references the related JIRA issue (" [FLINK-XXX] Jira title text") The pull request addresses only one issue Each commit in the PR has a meaningful commit message (including the JIRA id) [ ] Documentation Documentation has been added for new functionality Old documentation affected by the pull request has been updated JavaDoc for public methods has been added [x] Tests & Build Functionality added by the pull request is covered by tests `mvn clean verify` has been executed successfully locally or a Travis build has passed This PR adds the possibility to unregister tables. Although Calcite supports mutable schemas, deleting a table instead of replacing it was not easy to implement. I will add some documentation if you are fine with this PR. You can merge this pull request into a Git repository by running: $ git pull https://github.com/twalthr/flink FLINK-4288 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/flink/pull/2511.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #2511 commit 0ecb6138680498bdacb134eff1609b21cbb07cd9 Author: twalthr <twalthr@apache.org> Date: 2016-09-19T12:09:14Z FLINK-4288 [table] Make it possible to unregister tables
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user fhueske commented on a diff in the pull request:

          https://github.com/apache/flink/pull/2511#discussion_r88737674

          — Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/FlinkSchema.scala —
          @@ -0,0 +1,57 @@
          +/*
          + * Licensed to the Apache Software Foundation (ASF) under one
          + * or more contributor license agreements. See the NOTICE file
          + * distributed with this work for additional information
          + * regarding copyright ownership. The ASF licenses this file
          + * to you under the Apache License, Version 2.0 (the
          + * "License"); you may not use this file except in compliance
          + * with the License. You may obtain a copy of the License at
          + *
          + * http://www.apache.org/licenses/LICENSE-2.0
          + *
          + * Unless required by applicable law or agreed to in writing, software
          + * distributed under the License is distributed on an "AS IS" BASIS,
          + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
          + * See the License for the specific language governing permissions and
          + * limitations under the License.
          + */
          +
          +package org.apache.flink.api.table
          +
          +import java.util
          +
          +import org.apache.calcite.jdbc.CalciteSchema
          +import org.apache.calcite.jdbc.CalciteSchema.TableEntry
          +import org.apache.calcite.schema
          +import org.apache.calcite.schema.SchemaPlus
          +
          +/**
          + * Wraps [[CalciteSchema]] and allows for deleting tables.
          + */
          +class FlinkSchema {
          — End diff –

          I think the benefit of this wrapper is rather limited.
          Couldn't we just call `schema.tableMap.remove()` in `TableEnvironment`?

          Show
          githubbot ASF GitHub Bot added a comment - Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/2511#discussion_r88737674 — Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/FlinkSchema.scala — @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.api.table + +import java.util + +import org.apache.calcite.jdbc.CalciteSchema +import org.apache.calcite.jdbc.CalciteSchema.TableEntry +import org.apache.calcite.schema +import org.apache.calcite.schema.SchemaPlus + +/** + * Wraps [ [CalciteSchema] ] and allows for deleting tables. + */ +class FlinkSchema { — End diff – I think the benefit of this wrapper is rather limited. Couldn't we just call `schema.tableMap.remove()` in `TableEnvironment`?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user fhueske commented on a diff in the pull request:

          https://github.com/apache/flink/pull/2511#discussion_r88737982

          — Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/TableEnvironment.scala —
          @@ -133,12 +134,24 @@ abstract class TableEnvironment(val config: TableConfig)

          { registerTableInternal(name, tableTable) case e: StreamTableEnvironment => val sTableTable = new TransStreamTable(table.getRelNode, true) - tables.add(name, sTableTable) + schema.addTable(name, sTableTable) }

          }

          /**
          + * Unregisters a [[Table]] in the TableEnvironment's catalog.
          + * Unregistered tables cannot be referenced in SQL queries anymore.
          + *
          + * @param name The name under which the table is registered.
          + */
          + def unregisterTable(name: String): Unit = {
          — End diff –

          Do we want to return a boolean success value or throw an exception if the table does not exist?

          Show
          githubbot ASF GitHub Bot added a comment - Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/2511#discussion_r88737982 — Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/TableEnvironment.scala — @@ -133,12 +134,24 @@ abstract class TableEnvironment(val config: TableConfig) { registerTableInternal(name, tableTable) case e: StreamTableEnvironment => val sTableTable = new TransStreamTable(table.getRelNode, true) - tables.add(name, sTableTable) + schema.addTable(name, sTableTable) } } /** + * Unregisters a [ [Table] ] in the TableEnvironment's catalog. + * Unregistered tables cannot be referenced in SQL queries anymore. + * + * @param name The name under which the table is registered. + */ + def unregisterTable(name: String): Unit = { — End diff – Do we want to return a boolean success value or throw an exception if the table does not exist?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user fhueske commented on a diff in the pull request:

          https://github.com/apache/flink/pull/2511#discussion_r88737974

          — Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/TableEnvironment.scala —
          @@ -133,12 +134,24 @@ abstract class TableEnvironment(val config: TableConfig)

          { registerTableInternal(name, tableTable) case e: StreamTableEnvironment => val sTableTable = new TransStreamTable(table.getRelNode, true) - tables.add(name, sTableTable) + schema.addTable(name, sTableTable) }

          }

          /**
          + * Unregisters a [[Table]] in the TableEnvironment's catalog.
          + * Unregistered tables cannot be referenced in SQL queries anymore.
          + *
          + * @param name The name under which the table is registered.
          + */
          + def unregisterTable(name: String): Unit = {
          +
          + checkValidTableName(name)
          — End diff –

          Do we need to check if the name is valid? Couldn't we just try to delete it?

          Show
          githubbot ASF GitHub Bot added a comment - Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/2511#discussion_r88737974 — Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/TableEnvironment.scala — @@ -133,12 +134,24 @@ abstract class TableEnvironment(val config: TableConfig) { registerTableInternal(name, tableTable) case e: StreamTableEnvironment => val sTableTable = new TransStreamTable(table.getRelNode, true) - tables.add(name, sTableTable) + schema.addTable(name, sTableTable) } } /** + * Unregisters a [ [Table] ] in the TableEnvironment's catalog. + * Unregistered tables cannot be referenced in SQL queries anymore. + * + * @param name The name under which the table is registered. + */ + def unregisterTable(name: String): Unit = { + + checkValidTableName(name) — End diff – Do we need to check if the name is valid? Couldn't we just try to delete it?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user twalthr closed the pull request at:

          https://github.com/apache/flink/pull/2511

          Show
          githubbot ASF GitHub Bot added a comment - Github user twalthr closed the pull request at: https://github.com/apache/flink/pull/2511
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user twalthr commented on the issue:

          https://github.com/apache/flink/pull/2511

          I updated this PR. I will create a followup issue to refactor all TableEnvironment registration tests to unit tests.

          Show
          githubbot ASF GitHub Bot added a comment - Github user twalthr commented on the issue: https://github.com/apache/flink/pull/2511 I updated this PR. I will create a followup issue to refactor all TableEnvironment registration tests to unit tests.
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user twalthr reopened a pull request:

          https://github.com/apache/flink/pull/2511

          FLINK-4288 [table] Make it possible to unregister tables

          Thanks for contributing to Apache Flink. Before you open your pull request, please take the following check list into consideration.
          If your changes take all of the items into account, feel free to open your pull request. For more information and/or questions please refer to the [How To Contribute guide](http://flink.apache.org/how-to-contribute.html).
          In addition to going through the list, please provide a meaningful description of your changes.

          • [x] General
          • The pull request references the related JIRA issue ("[FLINK-XXX] Jira title text")
          • The pull request addresses only one issue
          • Each commit in the PR has a meaningful commit message (including the JIRA id)
          • [ ] Documentation
          • Documentation has been added for new functionality
          • Old documentation affected by the pull request has been updated
          • JavaDoc for public methods has been added
          • [x] Tests & Build
          • Functionality added by the pull request is covered by tests
          • `mvn clean verify` has been executed successfully locally or a Travis build has passed

          This PR adds the possibility to unregister tables. Although Calcite supports mutable schemas, deleting a table instead of replacing it was not easy to implement. I will add some documentation if you are fine with this PR.

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/twalthr/flink FLINK-4288

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/flink/pull/2511.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #2511


          commit 4b710ce5eee8629de691bb4cc2c7f9f7c3f76dcc
          Author: twalthr <twalthr@apache.org>
          Date: 2017-01-05T14:13:13Z

          FLINK-4288 [table] Make it possible to unregister tables


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user twalthr reopened a pull request: https://github.com/apache/flink/pull/2511 FLINK-4288 [table] Make it possible to unregister tables Thanks for contributing to Apache Flink. Before you open your pull request, please take the following check list into consideration. If your changes take all of the items into account, feel free to open your pull request. For more information and/or questions please refer to the [How To Contribute guide] ( http://flink.apache.org/how-to-contribute.html ). In addition to going through the list, please provide a meaningful description of your changes. [x] General The pull request references the related JIRA issue (" [FLINK-XXX] Jira title text") The pull request addresses only one issue Each commit in the PR has a meaningful commit message (including the JIRA id) [ ] Documentation Documentation has been added for new functionality Old documentation affected by the pull request has been updated JavaDoc for public methods has been added [x] Tests & Build Functionality added by the pull request is covered by tests `mvn clean verify` has been executed successfully locally or a Travis build has passed This PR adds the possibility to unregister tables. Although Calcite supports mutable schemas, deleting a table instead of replacing it was not easy to implement. I will add some documentation if you are fine with this PR. You can merge this pull request into a Git repository by running: $ git pull https://github.com/twalthr/flink FLINK-4288 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/flink/pull/2511.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #2511 commit 4b710ce5eee8629de691bb4cc2c7f9f7c3f76dcc Author: twalthr <twalthr@apache.org> Date: 2017-01-05T14:13:13Z FLINK-4288 [table] Make it possible to unregister tables
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user twalthr commented on the issue:

          https://github.com/apache/flink/pull/2511

          Thanks @fhueske. I will add some sentences to the documentation and merge this.

          Show
          githubbot ASF GitHub Bot added a comment - Github user twalthr commented on the issue: https://github.com/apache/flink/pull/2511 Thanks @fhueske. I will add some sentences to the documentation and merge this.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/flink/pull/2511

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/flink/pull/2511
          Hide
          twalthr Timo Walther added a comment -

          Fixed in 1.3.0: 33b8570e962e5bf6790c528f862b4c5af8322613.

          Show
          twalthr Timo Walther added a comment - Fixed in 1.3.0: 33b8570e962e5bf6790c528f862b4c5af8322613.

            People

            • Assignee:
              twalthr Timo Walther
              Reporter:
              twalthr Timo Walther
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development