diff --git a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcConf.java b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcConf.java index 81b822f4998e5b125e6acaff4005c3788891cb8a..132889c3986056ef640138aa19370d6e35f98eb8 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcConf.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcConf.java @@ -133,7 +133,7 @@ public String getDescription() { private String lookupValue(Properties tbl, Configuration conf) { String result = null; if (tbl != null) { - result = conf.get(attribute); + result = tbl.getProperty(attribute); } if (result == null && conf != null) { result = conf.get(attribute); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcSerde.java b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcSerde.java index a381443ea16eab719258a1ab6a98d6b468b7d3f3..8beff4b0c2dfc894bf6186bb96da1a3d87630020 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcSerde.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcSerde.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Properties; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; @@ -42,7 +43,7 @@ * A serde class for ORC. * It transparently passes the object to/from the ORC file reader/writer. */ -@SerDeSpec(schemaProps = {serdeConstants.LIST_COLUMNS, serdeConstants.LIST_COLUMN_TYPES}) +@SerDeSpec(schemaProps = {serdeConstants.LIST_COLUMNS, serdeConstants.LIST_COLUMN_TYPES, OrcSerde.COMPRESSION}) public class OrcSerde implements SerDe, VectorizedSerde { private static final Log LOG = LogFactory.getLog(OrcSerde.class); @@ -51,6 +52,7 @@ private ObjectInspector inspector = null; private VectorizedOrcSerde vos = null; + public static final String COMPRESSION = "orc.compress"; final class OrcSerdeRow implements Writable { Object realRow; @@ -82,6 +84,8 @@ public void initialize(Configuration conf, Properties table) { // NOTE: if "columns.types" is missing, all columns will be of String type String columnTypeProperty = table.getProperty(serdeConstants.LIST_COLUMN_TYPES); + String compressType = OrcConf.COMPRESS.getString(table, conf); + // Parse the configuration parameters ArrayList columnNames = new ArrayList(); if (columnNameProperty != null && columnNameProperty.length() > 0) { diff --git a/ql/src/test/queries/clientpositive/create_like.q b/ql/src/test/queries/clientpositive/create_like.q index 3b04702d74d1e609691af310ea38d9a59f2cec50..bd39731b377be3ebf95b4d2aeb6ba8f2052e35bd 100644 --- a/ql/src/test/queries/clientpositive/create_like.q +++ b/ql/src/test/queries/clientpositive/create_like.q @@ -83,3 +83,15 @@ DESCRIBE FORMATTED table6; drop table table5; +create table orc_table ( +time string) +stored as ORC tblproperties ("orc.compress"="SNAPPY"); + +create table orc_table_using_like like orc_table; + +describe formatted orc_table_using_like; + +drop table orc_table_using_like; + +drop table orc_table; + diff --git a/ql/src/test/results/clientpositive/create_like.q.out b/ql/src/test/results/clientpositive/create_like.q.out index c93b134912491483ca205409576ab893939e8971..a373178bbbcf5bf0b8402f94be3033d3320321e0 100644 --- a/ql/src/test/results/clientpositive/create_like.q.out +++ b/ql/src/test/results/clientpositive/create_like.q.out @@ -579,3 +579,69 @@ POSTHOOK: query: drop table table5 POSTHOOK: type: DROPTABLE POSTHOOK: Input: default@table5 POSTHOOK: Output: default@table5 +PREHOOK: query: create table orc_table ( +time string) +stored as ORC tblproperties ("orc.compress"="SNAPPY") +PREHOOK: type: CREATETABLE +PREHOOK: Output: database:default +PREHOOK: Output: default@orc_table +POSTHOOK: query: create table orc_table ( +time string) +stored as ORC tblproperties ("orc.compress"="SNAPPY") +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: database:default +POSTHOOK: Output: default@orc_table +PREHOOK: query: create table orc_table_using_like like orc_table +PREHOOK: type: CREATETABLE +PREHOOK: Output: database:default +PREHOOK: Output: default@orc_table_using_like +POSTHOOK: query: create table orc_table_using_like like orc_table +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: database:default +POSTHOOK: Output: default@orc_table_using_like +PREHOOK: query: describe formatted orc_table_using_like +PREHOOK: type: DESCTABLE +PREHOOK: Input: default@orc_table_using_like +POSTHOOK: query: describe formatted orc_table_using_like +POSTHOOK: type: DESCTABLE +POSTHOOK: Input: default@orc_table_using_like +# col_name data_type comment + +time string + +# Detailed Table Information +Database: default +#### A masked pattern was here #### +Retention: 0 +#### A masked pattern was here #### +Table Type: MANAGED_TABLE +Table Parameters: + orc.compress SNAPPY +#### A masked pattern was here #### + +# Storage Information +SerDe Library: org.apache.hadoop.hive.ql.io.orc.OrcSerde +InputFormat: org.apache.hadoop.hive.ql.io.orc.OrcInputFormat +OutputFormat: org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat +Compressed: No +Num Buckets: -1 +Bucket Columns: [] +Sort Columns: [] +Storage Desc Params: + serialization.format 1 +PREHOOK: query: drop table orc_table_using_like +PREHOOK: type: DROPTABLE +PREHOOK: Input: default@orc_table_using_like +PREHOOK: Output: default@orc_table_using_like +POSTHOOK: query: drop table orc_table_using_like +POSTHOOK: type: DROPTABLE +POSTHOOK: Input: default@orc_table_using_like +POSTHOOK: Output: default@orc_table_using_like +PREHOOK: query: drop table orc_table +PREHOOK: type: DROPTABLE +PREHOOK: Input: default@orc_table +PREHOOK: Output: default@orc_table +POSTHOOK: query: drop table orc_table +POSTHOOK: type: DROPTABLE +POSTHOOK: Input: default@orc_table +POSTHOOK: Output: default@orc_table