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

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

                Author: ASF GitHub Bot
            Created on: 02/Dec/21 08:28
            Start Date: 02/Dec/21 08:28
    Worklog Time Spent: 10m 
      Work Description: kasakrisz commented on a change in pull request #2777:
URL: https://github.com/apache/hive/pull/2777#discussion_r760859466



##########
File path: 
ql/src/test/results/clientpositive/llap/show_create_table_db_table.q.out
##########
@@ -120,8 +120,8 @@ POSTHOOK: query: SHOW CREATE TABLE tmp_feng.tmp_showcrt4
 POSTHOOK: type: SHOW_CREATETABLE
 POSTHOOK: Input: tmp_feng@tmp_showcrt4
 CREATE TABLE `tmp_feng`.`tmp_showcrt4`(
-  `s1` struct<`p1`:string>, 
-  `s2` struct<`p2`:array<map<int,uniontype<struct<`a`:int, `b`:string>, 
array<struct<`c`:int, `d`:string>>>>>>)
+  `s1` struct<``p1``:string>, 
+  `s2` struct<``p2``:array<map<int,uniontype<struct<``a``:int, ``b``:string>, 
array<struct<``c``:int, ``d``:string>>>>>>)

Review comment:
       I tried to run this generated create table statement from q test but it 
failed.
   The reason is that some struct fields names are escaped twice:
   ```
   structElementName = HiveUtils.unparseIdentifier(structElementName, 
Hive.get().getConf()); // <- first
   String structElementType = 
formatType(structTypeInfo.getAllStructFieldTypeInfos().get(i));
   
   structFormattedType.append("`" + structElementName + "`:" + 
structElementType); // <- second
   ```
   
   I also did some testing with struct fields having space and other special 
characters in their names. Unfortunately this is not supported so we can not 
create such tables.
   I think the line
   ```
   structElementName = HiveUtils.unparseIdentifier(structElementName, 
Hive.get().getConf());
   ```
   should be reverted and for now.




-- 
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: 689075)
    Time Spent: 5h  (was: 4h 50m)

> Add constraints in result of “SHOW CREATE TABLE ”
> -------------------------------------------------
>
>                 Key: HIVE-25652
>                 URL: https://issues.apache.org/jira/browse/HIVE-25652
>             Project: Hive
>          Issue Type: Improvement
>            Reporter: Soumyakanti Das
>            Assignee: Soumyakanti Das
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 5h
>  Remaining Estimate: 0h
>
> Currently show create table doesn’t pull any constraint info like not null, 
> defaults, primary key.
> Example:
> Create table
>  
> {code:java}
> CREATE TABLE TEST(
>   col1 varchar(100) NOT NULL COMMENT "comment for column 1",
>   col2 timestamp DEFAULT CURRENT_TIMESTAMP() COMMENT "comment for column 2",
>   col3 decimal,
>   col4 varchar(512) NOT NULL,
>   col5 varchar(100),
>   primary key(col1, col2) disable novalidate)
> ROW FORMAT SERDE
>   'org.apache.hadoop.hive.ql.io.orc.OrcSerde'
> STORED AS INPUTFORMAT
>   'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat'
> OUTPUTFORMAT
>   'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat';
> {code}
> Currently {{SHOW CREATE TABLE TEST}} doesn't show the column constraints.
> {code:java}
> CREATE TABLE `test`(
>   `col1` varchar(100) COMMENT 'comment for column 1', 
>   `col2` timestamp COMMENT 'comment for column 2', 
>   `col3` decimal(10,0), 
>   `col4` varchar(512), 
>   `col5` varchar(100))
> ROW FORMAT SERDE 
>   'org.apache.hadoop.hive.ql.io.orc.OrcSerde' 
> STORED AS INPUTFORMAT 
>   'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat' 
> OUTPUTFORMAT 
>   'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'
> {code}



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

Reply via email to