diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java index 161ea8e844..3c21f3b8e5 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java @@ -257,6 +257,7 @@ import org.apache.hadoop.hive.ql.util.DirectionUtils; import org.apache.hadoop.hive.ql.util.ResourceDownloader; import org.apache.hadoop.hive.serde.serdeConstants; +import org.apache.hadoop.hive.serde2.DelimitedJSONSerDe; import org.apache.hadoop.hive.serde2.Deserializer; import org.apache.hadoop.hive.serde2.MetadataTypedColumnsetSerDe; import org.apache.hadoop.hive.serde2.NoOpFetchFormatter; @@ -4010,9 +4011,13 @@ private Operator genScriptPlan(ASTNode trfm, QB qb, Operator input) .getChild(inputSerDeNum))).getChild(0), inpColumns.toString(), inpColumnTypes.toString()); } else { - inInfo = PlanUtils.getTableDesc(serde, Integer + // It is not a very clean way, and should be modified later - due to + // compatibility reasons, user sees the results as JSON for custom + // scripts and has no way for specifying that. Right now, it is + // hard-coded to DelimitedJSONSerDe + inInfo = PlanUtils.getTableDesc(DelimitedJSONSerDe.class, Integer .toString(fieldSeparator), inpColumns.toString(), inpColumnTypes - .toString(), false, true); + .toString(), false); } if (trfm.getChild(outputSerDeNum).getChildCount() > 0) { diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java index d9f88fe731..f33a4a494b 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java @@ -67,7 +67,6 @@ import org.apache.hadoop.hive.ql.session.SessionState; import org.apache.hadoop.hive.serde.serdeConstants; import org.apache.hadoop.hive.serde2.AbstractSerDe; -import org.apache.hadoop.hive.serde2.DelimitedJSONSerDe; import org.apache.hadoop.hive.serde2.Deserializer; import org.apache.hadoop.hive.serde2.binarysortable.BinarySortableSerDe; import org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe; @@ -234,26 +233,18 @@ public static TableDesc getDefaultTableDesc(String separatorCode, columnTypes, lastColumnTakesRestOfTheLine); } - public static TableDesc getTableDesc( - Class serdeClass, String separatorCode, - String columns, String columnTypes, boolean lastColumnTakesRestOfTheLine) { - return getTableDesc(serdeClass, separatorCode, columns, columnTypes, - lastColumnTakesRestOfTheLine, false); - } - - public static TableDesc getTableDesc( - Class serdeClass, String separatorCode, - String columns, String columnTypes, boolean lastColumnTakesRestOfTheLine, - boolean useDelimitedJSON) { + public static TableDesc getTableDesc(Class serdeClass, + String separatorCode, String columns, String columnTypes, + boolean lastColumnTakesRestOfTheLine) { return getTableDesc(serdeClass, separatorCode, columns, columnTypes, - lastColumnTakesRestOfTheLine, useDelimitedJSON, "TextFile"); + lastColumnTakesRestOfTheLine, "TextFile"); } public static TableDesc getTableDesc( Class serdeClass, String separatorCode, String columns, String columnTypes, boolean lastColumnTakesRestOfTheLine, - boolean useDelimitedJSON, String fileFormat) { + String fileFormat) { Properties properties = Utilities.makeProperties( serdeConstants.SERIALIZATION_FORMAT, separatorCode, serdeConstants.LIST_COLUMNS, @@ -272,15 +263,6 @@ public static TableDesc getTableDesc( "true"); } - // It is not a very clean way, and should be modified later - due to - // 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 - if (useDelimitedJSON) { - serdeClass = DelimitedJSONSerDe.class; - } - Class inputFormat, outputFormat; // get the input & output file formats if ("HiveSequenceFile".equalsIgnoreCase(fileFormat)) { @@ -308,7 +290,7 @@ public static TableDesc getTableDesc( public static TableDesc getDefaultQueryOutputTableDesc(String cols, String colTypes, String fileFormat, Class serdeClass) { TableDesc tblDesc = - getTableDesc(serdeClass, "" + Utilities.ctrlaCode, cols, colTypes, false, false, fileFormat); + getTableDesc(serdeClass, "" + Utilities.ctrlaCode, cols, colTypes, false, fileFormat); // enable escaping tblDesc.getProperties().setProperty(serdeConstants.ESCAPE_CHAR, "\\"); tblDesc.getProperties().setProperty(serdeConstants.SERIALIZATION_ESCAPE_CRLF, "true"); @@ -351,7 +333,7 @@ public static TableDesc getTableDesc(CreateTableDesc crtTblDesc, String cols, } ret = getTableDesc(serdeClass, separatorCode, columns, columnTypes, - lastColumnTakesRestOfTheLine, false); + lastColumnTakesRestOfTheLine); // set other table properties Properties properties = ret.getProperties(); @@ -448,7 +430,7 @@ public static TableDesc getTableDesc(CreateViewDesc crtViewDesc, String cols, St } ret = getTableDesc(serdeClass, separatorCode, columns, columnTypes, - lastColumnTakesRestOfTheLine, false); + lastColumnTakesRestOfTheLine); // set other table properties Properties properties = ret.getProperties();