soumyakanti3578 commented on a change in pull request #2752:
URL: https://github.com/apache/hive/pull/2752#discussion_r739579722



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/exec/DDLPlanUtils.java
##########
@@ -800,19 +804,59 @@ private String getExternal(Table table) {
     return table.getTableType() == TableType.EXTERNAL_TABLE ? "EXTERNAL " : "";
   }
 
-  private String getColumns(Table table) {
-    List<String> columnDescs = new ArrayList<String>();
+  private String getColumns(Table table) throws HiveException{
+    List<String> columnDescs = new ArrayList<>();
+    Set<String> notNullColumns = null;
+    if 
(NotNullConstraint.isNotNullConstraintNotEmpty(table.getNotNullConstraint())) {
+      notNullColumns = new 
HashSet<>(table.getNotNullConstraint().getNotNullConstraints().values());
+    }
+
+    Map<String, String> columnDefaultValueMap = null;
+    if 
(DefaultConstraint.isCheckConstraintNotEmpty(table.getDefaultConstraint())) {
+      columnDefaultValueMap = 
table.getDefaultConstraint().getColNameToDefaultValueMap();
+    }
     for (FieldSchema column : table.getCols()) {
       String columnType = 
formatType(TypeInfoUtils.getTypeInfoFromTypeString(column.getType()));
-      String columnDesc = "  `" + column.getName() + "` " + columnType;
+      String columnName = column.getName();
+      StringBuilder columnDesc = new StringBuilder();
+      columnDesc.append("  `").append(columnName).append("` 
").append(columnType);

Review comment:
       Do we really need the backticks? Removing them will make check 
constraints very easy, as we can directly use the check expression. Let's say 
the check expression is `col3 + col4 > 3`, and we don't get backticks here. If 
we don't use backticks anywhere, we can use this directly, otherwise we'll have 
to somehow figure out the column names and add backticks around it, which will 
make it a bit more complex.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to