FAQ
Author: heyongqiang
Date: Tue Nov 30 07:03:49 2010
New Revision: 1040422

URL: http://svn.apache.org/viewvc?rev=1040422&view=rev
Log:
HIVE-138 Provide option to export a HEADER. (Paul Butler via He Yongqiang)

Added:
hive/trunk/ql/src/test/queries/clientpositive/print_header.q
hive/trunk/ql/src/test/results/clientpositive/print_header.q.out
Modified:
hive/trunk/CHANGES.txt
hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java
hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
hive/trunk/conf/hive-default.xml

Modified: hive/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hive/trunk/CHANGES.txt?rev=1040422&r1=1040421&r2=1040422&view=diff
==============================================================================
--- hive/trunk/CHANGES.txt (original)
+++ hive/trunk/CHANGES.txt Tue Nov 30 07:03:49 2010
@@ -280,6 +280,9 @@ Trunk - Unreleased
HIVE-1797 Compressed the hashtable dump file before put into distributed cache
(Liyin Tang via He Yongqiang)

+ HIVE-138 Provide option to export a HEADER
+ (Paul Butler via He Yongqiang)
+
OPTIMIZATIONS

BUG FIXES

Modified: hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java
URL: http://svn.apache.org/viewvc/hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java?rev=1040422&r1=1040421&r2=1040422&view=diff
==============================================================================
--- hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java (original)
+++ hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java Tue Nov 30 07:03:49 2010
@@ -50,6 +50,8 @@ import org.apache.hadoop.hive.ql.process
import org.apache.hadoop.hive.ql.session.SessionState;
import org.apache.hadoop.hive.ql.session.SessionState.LogHelper;
import org.apache.hadoop.hive.shims.ShimLoader;
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hadoop.hive.metastore.api.Schema;

/**
* CliDriver.
@@ -144,6 +146,21 @@ public class CliDriver {
}

ArrayList<String> res = new ArrayList<String>();
+
+ if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_CLI_PRINT_HEADER)) {
+ // Print the column names
+ boolean first_col = true;
+ Schema sc = qp.getSchema();
+ for (FieldSchema fs : sc.getFieldSchemas()) {
+ if (!first_col) {
+ out.print('\t');
+ }
+ out.print(fs.getName());
+ first_col = false;
+ }
+ out.println();
+ }
+
try {
while (qp.getResults(res)) {
for (String r : res) {

Modified: hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
URL: http://svn.apache.org/viewvc/hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java?rev=1040422&r1=1040421&r2=1040422&view=diff
==============================================================================
--- hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (original)
+++ hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java Tue Nov 30 07:03:49 2010
@@ -315,6 +315,9 @@ public class HiveConf extends Configurat
HIVEFETCHOUTPUTSERDE("hive.fetch.output.serde", "org.apache.hadoop.hive.serde2.DelimitedJSONSerDe"),

SEMANTIC_ANALYZER_HOOK("hive.semantic.analyzer.hook",null),
+
+ // Print column names in output
+ HIVE_CLI_PRINT_HEADER("hive.cli.print.header", false);
;



Modified: hive/trunk/conf/hive-default.xml
URL: http://svn.apache.org/viewvc/hive/trunk/conf/hive-default.xml?rev=1040422&r1=1040421&r2=1040422&view=diff
==============================================================================
--- hive/trunk/conf/hive-default.xml (original)
+++ hive/trunk/conf/hive-default.xml Tue Nov 30 07:03:49 2010
@@ -36,6 +36,12 @@
</property>

<property>
+ <name>hive.cli.print.header</name>
+ <value>false</value>
+ <description>Whether to print the names of the columns in query output.</description>
+</property>
+
+<property>
<name>hive.exec.scratchdir</name>
<value>/tmp/hive-${user.name}</value>
<description>Scratch space for Hive jobs</description>

Added: hive/trunk/ql/src/test/queries/clientpositive/print_header.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/print_header.q?rev=1040422&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/print_header.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/print_header.q Tue Nov 30 07:03:49 2010
@@ -0,0 +1,13 @@
+
+set hive.cli.print.header=true;
+
+SELECT src1.key as k1, src1.value as v1,
+ src2.key as k2, src2.value as v2 FROM
+ (SELECT * FROM src WHERE src.key < 10) src1
+ JOIN
+ (SELECT * FROM src WHERE src.key < 10) src2
+ SORT BY k1, v1, k2, v2
+ LIMIT 10;
+
+SELECT src.key, sum(substr(src.value,5)) FROM src GROUP BY src.key LIMIT 10;
+

Added: hive/trunk/ql/src/test/results/clientpositive/print_header.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/print_header.q.out?rev=1040422&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/print_header.q.out (added)
+++ hive/trunk/ql/src/test/results/clientpositive/print_header.q.out Tue Nov 30 07:03:49 2010
@@ -0,0 +1,50 @@
+PREHOOK: query: SELECT src1.key as k1, src1.value as v1,
+ src2.key as k2, src2.value as v2 FROM
+ (SELECT * FROM src WHERE src.key < 10) src1
+ JOIN
+ (SELECT * FROM src WHERE src.key < 10) src2
+ SORT BY k1, v1, k2, v2
+ LIMIT 10
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/tmp/pbutler/hive_2010-11-22_13-41-11_283_258399688654159660/-mr-10000
+POSTHOOK: query: SELECT src1.key as k1, src1.value as v1,
+ src2.key as k2, src2.value as v2 FROM
+ (SELECT * FROM src WHERE src.key < 10) src1
+ JOIN
+ (SELECT * FROM src WHERE src.key < 10) src2
+ SORT BY k1, v1, k2, v2
+ LIMIT 10
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/tmp/pbutler/hive_2010-11-22_13-41-11_283_258399688654159660/-mr-10000
+k1 v1 k2 v2
+0 val_0 0 val_0
+0 val_0 0 val_0
+0 val_0 0 val_0
+0 val_0 0 val_0
+0 val_0 0 val_0
+0 val_0 0 val_0
+0 val_0 0 val_0
+0 val_0 0 val_0
+0 val_0 0 val_0
+0 val_0 2 val_2
+PREHOOK: query: SELECT src.key, sum(substr(src.value,5)) FROM src GROUP BY src.key LIMIT 10
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/tmp/pbutler/hive_2010-11-22_13-41-30_510_2595029549749893604/-mr-10000
+POSTHOOK: query: SELECT src.key, sum(substr(src.value,5)) FROM src GROUP BY src.key LIMIT 10
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/tmp/pbutler/hive_2010-11-22_13-41-30_510_2595029549749893604/-mr-10000
+key _c1
+0 0.0
+10 10.0
+100 200.0
+103 206.0
+104 208.0
+105 105.0
+11 11.0
+111 111.0
+113 226.0
+114 114.0

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categorieshive, hadoop
postedNov 30, '10 at 7:05a
activeNov 30, '10 at 7:05a
posts1
users1
websitehive.apache.org

1 user in discussion

Heyongqiang: 1 post

People

Translate

site design / logo © 2021 Grokbase