[ 
https://issues.apache.org/jira/browse/HIVE-25963?focusedWorklogId=736218&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-736218
 ]

ASF GitHub Bot logged work on HIVE-25963:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 03/Mar/22 18:44
            Start Date: 03/Mar/22 18:44
    Worklog Time Spent: 10m 
      Work Description: sourabh912 commented on a change in pull request #3040:
URL: https://github.com/apache/hive/pull/3040#discussion_r818961752



##########
File path: 
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
##########
@@ -1247,31 +1247,11 @@ public void createTable(Table tbl) throws 
AlreadyExistsException,
 
   public void createTable(Table tbl, EnvironmentContext envContext) throws 
AlreadyExistsException,
       InvalidObjectException, MetaException, NoSuchObjectException, TException 
{
-    if (!tbl.isSetCatName()) {
-      tbl.setCatName(getDefaultCatalog(conf));
-    }
-    HiveMetaHook hook = getHook(tbl);
-    if (hook != null) {
-      hook.preCreateTable(tbl);
-    }
-    boolean success = false;
-    try {
-      // Subclasses can override this step (for example, for temporary tables)
-      create_table_with_environment_context(tbl, envContext);
-      if (hook != null) {
-        hook.commitCreateTable(tbl);
-      }
-      success = true;
-    }
-    finally {
-      if (!success && (hook != null)) {
-        try {
-          hook.rollbackCreateTable(tbl);
-        } catch (Exception e){
-          LOG.error("Create rollback failed with", e);
-        }
-      }
+    CreateTableRequest request = new CreateTableRequest(tbl);
+    if (envContext != null) {
+      request.setEnvContext(envContext);
     }
+    createTable(request);

Review comment:
       `createTable(request)` method at line number 1284 is taking care of that 
already.




-- 
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: gitbox-unsubscr...@hive.apache.org

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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 736218)
    Time Spent: 1.5h  (was: 1h 20m)

> Temporary table creation with not null constraint gets converted to external 
> table 
> -----------------------------------------------------------------------------------
>
>                 Key: HIVE-25963
>                 URL: https://issues.apache.org/jira/browse/HIVE-25963
>             Project: Hive
>          Issue Type: Bug
>          Components: HiveServer2, Standalone Metastore
>            Reporter: Sourabh Goyal
>            Assignee: Sourabh Goyal
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> When creating a temporary table with not null, constraint it gets covered to 
> external table. For example: 
> create temporary table t2 (a int not null);
> table t2' metadata looks like: 
> {code:java}
> +-------------------------------+----------------------------------------------------+----------------------------------------------------+
> |           col_name            |                     data_type               
>        |                      comment                       |
> +-------------------------------+----------------------------------------------------+----------------------------------------------------+
> | a                             | int                                         
>        |                                                    |
> |                               | NULL                                        
>        | NULL                                               |
> | # Detailed Table Information  | NULL                                        
>        | NULL                                               |
> | Database:                     | default                                     
>        | NULL                                               |
> | OwnerType:                    | USER                                        
>        | NULL                                               |
> | Owner:                        | sourabh                                     
>        | NULL                                               |
> | CreateTime:                   | Tue Feb 15 15:20:13 PST 2022                
>        | NULL                                               |
> | LastAccessTime:               | UNKNOWN                                     
>        | NULL                                               |
> | Retention:                    | 0                                           
>        | NULL                                               |
> | Location:                     | 
> hdfs://localhost:9000/tmp/hive/sourabh/80d374a8-cd7a-4fcf-ae72-51b04ff9c3d8/_tmp_space.db/4574446d-c144-48f9-b4b6-2e9ee0ce5be4
>  | NULL                                               |
> | Table Type:                   | EXTERNAL_TABLE                              
>        | NULL                                               |
> | Table Parameters:             | NULL                                        
>        | NULL                                               |
> |                               | COLUMN_STATS_ACCURATE                       
>        | {\"BASIC_STATS\":\"true\",\"COLUMN_STATS\":{\"a\":\"true\"}} |
> |                               | EXTERNAL                                    
>        | TRUE                                               |
> |                               | TRANSLATED_TO_EXTERNAL                      
>        | TRUE                                               |
> |                               | bucketing_version                           
>        | 2                                                  |
> |                               | external.table.purge                        
>        | TRUE                                               |
> |                               | numFiles                                    
>        | 0                                                  |
> |                               | numRows                                     
>        | 0                                                  |
> |                               | rawDataSize                                 
>        | 0                                                  |
> |                               | totalSize                                   
>        | 0                                                  |
> |                               | transient_lastDdlTime                       
>        | 1644967213                                         |
> |                               | NULL                                        
>        | NULL                                               |
> | # Storage Information         | NULL                                        
>        | NULL                                               |
> | SerDe Library:                | 
> org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe | NULL                     
>                           |
> | InputFormat:                  | org.apache.hadoop.mapred.TextInputFormat    
>        | NULL                                               |
> | OutputFormat:                 | 
> org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat | NULL             
>                                   |
> | Compressed:                   | No                                          
>        | NULL                                               |
> | Num Buckets:                  | -1                                          
>        | NULL                                               |
> | Bucket Columns:               | []                                          
>        | NULL                                               |
> | Sort Columns:                 | []                                          
>        | NULL                                               |
> | Storage Desc Params:          | NULL                                        
>        | NULL                                               |
> |                               | serialization.format                        
>        | 1                                                  |
> |                               | NULL                                        
>        | NULL                                               |
> | # Constraints                 | NULL                                        
>        | NULL                                               |
> |                               | NULL                                        
>        | NULL                                               |
> | # Not Null Constraints        | NULL                                        
>        | NULL                                               |
> | Table:                        | default.t2                                  
>        | NULL                                               |
> | Constraint Name:              | nn_157620106_1644967213860_0                
>        | NULL                                               |
> | Column Name:                  | a                                           
>        | NULL                                               |
> |                               | NULL                                        
>        | NULL                                               |
> +-------------------------------+----------------------------------------------------+----------------------------------------------------+
>  {code}
> However if a temporary table is created *without,* not null constraint, it 
> works as expected. For example: 
> create temporary table t5 (a int);
>  
> {code:java}
> +-------------------------------+----------------------------------------------------+----------------------------------------------------+
> |           col_name            |                     data_type               
>        |                      comment                       |
> +-------------------------------+----------------------------------------------------+----------------------------------------------------+
> | a                             | int                                         
>        |                                                    |
> |                               | NULL                                        
>        | NULL                                               |
> | # Detailed Table Information  | NULL                                        
>        | NULL                                               |
> | Database:                     | default                                     
>        | NULL                                               |
> | OwnerType:                    | USER                                        
>        | NULL                                               |
> | Owner:                        | sourabh                                     
>        | NULL                                               |
> | CreateTime:                   | Tue Feb 15 15:34:44 PST 2022                
>        | NULL                                               |
> | LastAccessTime:               | UNKNOWN                                     
>        | NULL                                               |
> | Retention:                    | 0                                           
>        | NULL                                               |
> | Location:                     | 
> hdfs://localhost:9000/tmp/hive/sourabh/22fcb5c1-b9a6-4d51-8efc-86d7c167a242/_tmp_space.db/0515167f-ca1a-4c53-a1de-e4385fc96079
>  | NULL                                               |
> | Table Type:                   | MANAGED_TABLE                               
>        | NULL                                               |
> | Table Parameters:             | NULL                                        
>        | NULL                                               |
> |                               | COLUMN_STATS_ACCURATE                       
>        | {\"BASIC_STATS\":\"true\",\"COLUMN_STATS\":{\"a\":\"true\"}} |
> |                               | bucketing_version                           
>        | 2                                                  |
> |                               | numFiles                                    
>        | 0                                                  |
> |                               | numRows                                     
>        | 0                                                  |
> |                               | rawDataSize                                 
>        | 0                                                  |
> |                               | totalSize                                   
>        | 0                                                  |
> |                               | NULL                                        
>        | NULL                                               |
> | # Storage Information         | NULL                                        
>        | NULL                                               |
> | SerDe Library:                | 
> org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe | NULL                     
>                           |
> | InputFormat:                  | org.apache.hadoop.mapred.TextInputFormat    
>        | NULL                                               |
> | OutputFormat:                 | 
> org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat | NULL             
>                                   |
> | Compressed:                   | No                                          
>        | NULL                                               |
> | Num Buckets:                  | -1                                          
>        | NULL                                               |
> | Bucket Columns:               | []                                          
>        | NULL                                               |
> | Sort Columns:                 | []                                          
>        | NULL                                               |
> | Storage Desc Params:          | NULL                                        
>        | NULL                                               |
> |                               | serialization.format                        
>        | 1                                                  |
> +-------------------------------+----------------------------------------------------+----------------------------------------------------+
>  
> {code}
> Temporary tables are managed tables as HS2 keeps them in memory. Their 
> metadata is not persisted in HMS.
> But  the above temp table t2 got converted into external table metadata for 
> which gets persisted into HMS which is not the desired behavior.
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to