Review Board 1.7.22


HIVE-1466: Add NULL DEFINED AS to ROW FORMAT specification

Review Request #16207 - Created Dec. 12, 2013 and updated

Prasad Mujumdar
trunk
HIVE-1466
Reviewers
hive
xuefu
hive-git
Support configurable null format for tables and writing out to directory.
Using a non-default null format is a bit while creating a table, and pretty much impossible to export the data to local filesystem using insert overwrite directory.
The patch enhances the SQL syntax to support 'NULL DEFINED AS' construct for create table as well as insert overwrite directory.
Added new tests.
ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
Revision 41df473 New Change
[20] 2068 lines
[+20] [+] private int showCreateTable(Hive db, ShowCreateTableDesc showCreateTbl) throws HiveException {
2069
          if (delims.containsKey(serdeConstants.LINE_DELIM)) {
2069
          if (delims.containsKey(serdeConstants.LINE_DELIM)) {
2070
            tbl_row_format += "  LINES TERMINATED BY '" +
2070
            tbl_row_format += "  LINES TERMINATED BY '" +
2071
                escapeHiveCommand(StringEscapeUtils.escapeJava(delims.get(
2071
                escapeHiveCommand(StringEscapeUtils.escapeJava(delims.get(
2072
                serdeConstants.LINE_DELIM))) + "' \n";
2072
                serdeConstants.LINE_DELIM))) + "' \n";
2073
          }
2073
          }

    
   
2074
          if (delims.containsKey(serdeConstants.SERIALIZATION_NULL_FORMAT)) {

    
   
2075
            tbl_row_format += "  NULL DEFINED AS '" +

    
   
2076
                escapeHiveCommand(StringEscapeUtils.escapeJava(delims.get(

    
   
2077
                serdeConstants.SERIALIZATION_NULL_FORMAT))) + "' \n";

    
   
2078
          }
2074
        }
2079
        }
2075
        else {
2080
        else {
2076
          tbl_row_format += " SERDE \n  '" +
2081
          tbl_row_format += " SERDE \n  '" +
2077
              escapeHiveCommand(serdeInfo.getSerializationLib()) + "' \n";
2082
              escapeHiveCommand(serdeInfo.getSerializationLib()) + "' \n";
2078
        }
2083
        }
[+20] [20] 1603 lines
[+20] [+] private int createTable(Hive db, CreateTableDesc crtTbl) throws HiveException {
3682
      tbl.setSerdeParam(serdeConstants.MAPKEY_DELIM, crtTbl.getMapKeyDelim());
3687
      tbl.setSerdeParam(serdeConstants.MAPKEY_DELIM, crtTbl.getMapKeyDelim());
3683
    }
3688
    }
3684
    if (crtTbl.getLineDelim() != null) {
3689
    if (crtTbl.getLineDelim() != null) {
3685
      tbl.setSerdeParam(serdeConstants.LINE_DELIM, crtTbl.getLineDelim());
3690
      tbl.setSerdeParam(serdeConstants.LINE_DELIM, crtTbl.getLineDelim());
3686
    }
3691
    }
3687

    
   
3692
    if (crtTbl.getNullFormat() != null) {

    
   
3693
      tbl.setSerdeParam(serdeConstants.SERIALIZATION_NULL_FORMAT, crtTbl.getNullFormat());

    
   
3694
    }
3688
    if (crtTbl.getSerdeProps() != null) {
3695
    if (crtTbl.getSerdeProps() != null) {
3689
      Iterator<Entry<String, String>> iter = crtTbl.getSerdeProps().entrySet()
3696
      Iterator<Entry<String, String>> iter = crtTbl.getSerdeProps().entrySet()
3690
        .iterator();
3697
        .iterator();
3691
      while (iter.hasNext()) {
3698
      while (iter.hasNext()) {
3692
        Entry<String, String> m = iter.next();
3699
        Entry<String, String> m = iter.next();
[+20] [20] 355 lines
ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java
Revision fdc0d1a New Change
 
ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g
Revision 366b714 New Change
 
ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
Revision b146df6 New Change
 
ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
Revision 8cf5ad6 New Change
 
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
Revision ace1df9 New Change
 
ql/src/java/org/apache/hadoop/hive/ql/plan/CreateTableDesc.java
Revision 93b4181 New Change
 
ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java
Revision b6097b1 New Change
 
ql/src/test/queries/clientpositive/nullformat.q
New File
 
ql/src/test/queries/clientpositive/nullformatCTAS.q
New File
 
ql/src/test/queries/clientpositive/nullformatdir.q
New File
 
ql/src/test/results/clientpositive/nullformat.q.out
New File
 
ql/src/test/results/clientpositive/nullformatCTAS.q.out
New File
 
ql/src/test/results/clientpositive/nullformatdir.q.out
New File
 
  1. ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java: Loading...
  2. ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java: Loading...
  3. ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g: Loading...
  4. ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g: Loading...
  5. ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g: Loading...
  6. ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java: Loading...
  7. ql/src/java/org/apache/hadoop/hive/ql/plan/CreateTableDesc.java: Loading...
  8. ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java: Loading...
  9. ql/src/test/queries/clientpositive/nullformat.q: Loading...
  10. ql/src/test/queries/clientpositive/nullformatCTAS.q: Loading...
  11. ql/src/test/queries/clientpositive/nullformatdir.q: Loading...
  12. ql/src/test/results/clientpositive/nullformat.q.out: Loading...
  13. ql/src/test/results/clientpositive/nullformatCTAS.q.out: Loading...
  14. ql/src/test/results/clientpositive/nullformatdir.q.out: Loading...