diff --git a/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java b/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java index 423939226a30..a539d7dfd8db 100644 --- a/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java +++ b/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java @@ -333,9 +333,14 @@ private void printHeader(Driver qp, PrintStream out) { && fieldSchemas != null) { // Print the column names boolean first_col = true; + String serializationFormat = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_LISTSINK_SERIALIZATION_FORMAT); for (FieldSchema fs : fieldSchemas) { if (!first_col) { - out.print('\t'); + if (!StringUtils.isEmpty(serializationFormat)) { + out.print((char)Integer.parseInt(serializationFormat)); + } else { + out.print('\t'); + } } out.print(fs.getName()); first_col = false; diff --git a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index e052d898699f..980930d2d7dd 100644 --- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -767,6 +767,8 @@ public static enum ConfVars { HIVESERVER_KERBEROS_KEYTAB_FILE("hive.hiveserver.kerberos.keytab.file", ""), HIVESERVER_KERBEROS_PRINCIPAL("hive.hiveserver.kerberos.principal", ""), HIVESERVER_USE_THRIFT_SASL("hive.hiveserver.sasl.enabled", false), + + HIVE_LISTSINK_SERIALIZATION_FORMAT("hive.listsink.serialization.format", ""), ; public final String varname; diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/ListSinkOperator.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/ListSinkOperator.java index 0174bcf57a75..6489fece96af 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/ListSinkOperator.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/ListSinkOperator.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Properties; +import org.apache.commons.lang.StringUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hive.common.JavaUtils; import org.apache.hadoop.hive.conf.HiveConf; @@ -65,7 +66,12 @@ private SerDe initializeSerde(Configuration conf) throws Exception { // this is the default serialization format if (serde instanceof DelimitedJSONSerDe) { - serdeProp.put(serdeConstants.SERIALIZATION_FORMAT, "" + Utilities.tabCode); + String serializationFormat = getConfiguration().get(HiveConf.ConfVars.HIVE_LISTSINK_SERIALIZATION_FORMAT.varname); + if (!StringUtils.isEmpty(serializationFormat)) { + serdeProp.put(serdeConstants.SERIALIZATION_FORMAT, "" + Integer.parseInt(serializationFormat)); + } else { + serdeProp.put(serdeConstants.SERIALIZATION_FORMAT, "" + Utilities.tabCode); + } serdeProp.put(serdeConstants.SERIALIZATION_NULL_FORMAT, getConf().getSerializationNullFormat()); } serde.initialize(conf, serdeProp);