You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by na...@apache.org on 2014/01/22 06:09:00 UTC
svn commit: r1560251 -
/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java
Author: navis
Date: Wed Jan 22 05:09:00 2014
New Revision: 1560251
URL: http://svn.apache.org/r1560251
Log:
HIVE-6083 : User provided table properties are not assigned to the TableDesc of the FileSinkDesc in a CTAS query (Yin Huai via Navis)
Modified:
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java?rev=1560251&r1=1560250&r2=1560251&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java Wed Jan 22 05:09:00 2014
@@ -85,7 +85,7 @@ public final class PlanUtils {
FIELD, JEXL
};
- public static long getCountForMapJoinDumpFilePrefix() {
+ public static synchronized long getCountForMapJoinDumpFilePrefix() {
return countForMapJoinDumpFilePrefix++;
}
@@ -103,46 +103,51 @@ public final class PlanUtils {
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
@@ -150,7 +155,7 @@ public final class PlanUtils {
e.printStackTrace();
return null;
}
- return tableDesc;
+ return ret;
}
/**
@@ -245,7 +250,7 @@ public final class PlanUtils {
}
// It is not a very clean way, and should be modified later - due to
- // compatiblity reasons,
+ // compatibility reasons,
// user sees the results as json for custom scripts and has no way for
// specifying that.
// Right now, it is hard-coded in the code
@@ -340,6 +345,10 @@ public final class PlanUtils {
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());
@@ -465,7 +474,7 @@ public final class PlanUtils {
/**
* Convert the ColumnList to FieldSchema list.
*
- * Adds uniontype for distinctColIndices.
+ * Adds union type for distinctColIndices.
*/
public static List<FieldSchema> getFieldSchemasFromColumnListWithLength(
List<ExprNodeDesc> cols, List<List<Integer>> distinctColIndices,