diff --git ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java index cdd8b9c..bd304a4 100644 --- ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java +++ ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java @@ -101,46 +101,51 @@ public static MapredWork getMapRedWork() { public static TableDesc getDefaultTableDesc(CreateTableDesc localDirectoryDesc, String cols, String colTypes ) { - TableDesc tableDesc = getDefaultTableDesc(Integer.toString(Utilities.ctrlaCode), cols, + TableDesc ret = getDefaultTableDesc(Integer.toString(Utilities.ctrlaCode), cols, colTypes, false);; if (localDirectoryDesc == null) { - return tableDesc; + return ret; } try { + Properties properties = ret.getProperties(); + if (localDirectoryDesc.getFieldDelim() != null) { - tableDesc.getProperties().setProperty( + properties.setProperty( serdeConstants.FIELD_DELIM, localDirectoryDesc.getFieldDelim()); - tableDesc.getProperties().setProperty( + properties.setProperty( serdeConstants.SERIALIZATION_FORMAT, localDirectoryDesc.getFieldDelim()); } if (localDirectoryDesc.getLineDelim() != null) { - tableDesc.getProperties().setProperty( + properties.setProperty( serdeConstants.LINE_DELIM, localDirectoryDesc.getLineDelim()); } if (localDirectoryDesc.getCollItemDelim() != null) { - tableDesc.getProperties().setProperty( + properties.setProperty( serdeConstants.COLLECTION_DELIM, localDirectoryDesc.getCollItemDelim()); } if (localDirectoryDesc.getMapKeyDelim() != null) { - tableDesc.getProperties().setProperty( + properties.setProperty( serdeConstants.MAPKEY_DELIM, localDirectoryDesc.getMapKeyDelim()); } if (localDirectoryDesc.getFieldEscape() !=null) { - tableDesc.getProperties().setProperty( + properties.setProperty( serdeConstants.ESCAPE_CHAR, localDirectoryDesc.getFieldEscape()); } if (localDirectoryDesc.getSerName() != null) { - tableDesc.getProperties().setProperty( + properties.setProperty( serdeConstants.SERIALIZATION_LIB, localDirectoryDesc.getSerName()); } if (localDirectoryDesc.getOutputFormat() != null){ - tableDesc.setOutputFileFormatClass(Class.forName(localDirectoryDesc.getOutputFormat())); + ret.setOutputFileFormatClass(Class.forName(localDirectoryDesc.getOutputFormat())); } if (localDirectoryDesc.getNullFormat() != null) { - tableDesc.getProperties().setProperty(serdeConstants.SERIALIZATION_NULL_FORMAT, + properties.setProperty(serdeConstants.SERIALIZATION_NULL_FORMAT, localDirectoryDesc.getNullFormat()); } + if (localDirectoryDesc.getTblProps() != null) { + properties.putAll(localDirectoryDesc.getTblProps()); + } } catch (ClassNotFoundException e) { // mimicking behaviour in CreateTableDesc tableDesc creation @@ -148,7 +153,7 @@ public static TableDesc getDefaultTableDesc(CreateTableDesc localDirectoryDesc, e.printStackTrace(); return null; } - return tableDesc; + return ret; } /** @@ -338,6 +343,10 @@ public static TableDesc getTableDesc(CreateTableDesc crtTblDesc, String cols, crtTblDesc.getDatabaseName() + "." + crtTblDesc.getTableName()); } + if (crtTblDesc.getTblProps() != null) { + properties.putAll(crtTblDesc.getTblProps()); + } + // replace the default input & output file format with those found in // crtTblDesc Class c1 = Class.forName(crtTblDesc.getInputFormat());