drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paul-rogers <...@git.apache.org>
Subject [GitHub] drill pull request #666: DRILL-4956: Temporary tables support
Date Thu, 05 Jan 2017 02:34:21 GMT
Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/666#discussion_r94704385
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ViewHandler.java
---
    @@ -49,6 +50,24 @@ public ViewHandler(SqlHandlerConfig config) {
         this.context = config.getContext();
       }
     
    +  /**
    +   * If view to be dropped is in default temporary workspace, checks if it's a temporary
table or not.
    +   *
    +   * @param schema view schema
    +   * @param viewName view name to be created
    +   * @return true is object to be created is temporary table, false otherwise
    +   */
    +  protected boolean isTemporaryTable(AbstractSchema schema, String viewName) {
    +    if (schema.getFullSchemaName().equals(context.getConfig().getString(ExecConstants.DEFAULT_TEMPORARY_WORKSPACE)))
{
    +      String temporaryTableName = context.getSession().findTemporaryTable(viewName);
    +      if (temporaryTableName != null) {
    +        Table temporaryTable = SqlHandlerUtil.getTableFromSchema(schema, temporaryTableName);
    +        return temporaryTable != null && temporaryTable.getJdbcTableType() ==
Schema.TableType.TABLE;
    --- End diff --
    
    After reading this same chunk of code in multiple places, I wonder if we can just do this:
    
    ```
    enum TempTableStatus { NOT_TEMP, NEW_TEMP, EXISTING_TEMP }
    class TempTableResult {
        TempTableStatus status;
        String resolvedName;
    }
    
    TempTableStatus resolveTempTable(List<String> name, ... ) {
    ...
    ```
    
    That is, in one place, do the work of checking if table is temp, if it exists in the name
space, and if so, what its (internal?) name is.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message