IMPALA-4686: Fix schema output for INT96 columns in parquet-reader tool

Instead of manually mapping the types we can just look them up in the
thrift map.

Testing: I tested this change manually by compiling the tool and running
it on a parquet file that had a INT96 column. Here is the relevant
output:

Schema:
id  INT32
bool_col  BOOLEAN
tinyint_col  INT32
smallint_col  INT32
int_col  INT32
bigint_col  INT64
float_col  FLOAT
double_col  DOUBLE
date_string_col  BYTE_ARRAY
string_col  BYTE_ARRAY
timestamp_col  INT96
year  INT32
month  INT32

We only use this tool in one test currently, which calls it to make sure
that a parquet-file can be parsed by it. This implies that we have tests
that it compiles, but we don't make use of its output currently.

Change-Id: I5d92f5556554c71461a93fe0d598bb69f91cce51
Reviewed-on: http://gerrit.cloudera.org:8080/5536
Reviewed-by: Lars Volker <[email protected]>
Reviewed-by: Matthew Jacobs <[email protected]>
Tested-by: Internal Jenkins


Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/68131b31
Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/68131b31
Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/68131b31

Branch: refs/heads/master
Commit: 68131b311577e6e16bfe5ef08b17a2312cc65296
Parents: 26f0b46
Author: Lars Volker <[email protected]>
Authored: Fri Dec 16 11:54:40 2016 -0800
Committer: Internal Jenkins <[email protected]>
Committed: Sat Dec 17 00:32:46 2016 +0000

----------------------------------------------------------------------
 be/src/util/parquet-reader.cc | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/68131b31/be/src/util/parquet-reader.cc
----------------------------------------------------------------------
diff --git a/be/src/util/parquet-reader.cc b/be/src/util/parquet-reader.cc
index d48ef16..afbb33d 100644
--- a/be/src/util/parquet-reader.cc
+++ b/be/src/util/parquet-reader.cc
@@ -86,22 +86,9 @@ bool DeserializeThriftMsg(uint8_t* buf, uint32_t* len, bool 
compact,
 }
 
 string TypeMapping(Type::type t) {
-  switch (t) {
-    case Type::BOOLEAN:
-      return "BOOLEAN";
-    case Type::INT32:
-      return "INT32";
-    case Type::INT64:
-      return "INT64";
-    case Type::FLOAT:
-      return "FLOAT";
-    case Type::DOUBLE:
-      return "DOUBLE";
-    case Type::BYTE_ARRAY:
-      return "BYTE_ARRAY";
-    default:
-      return "UNKNOWN";
-  }
+  auto it = _Type_VALUES_TO_NAMES.find(t);
+  if (it != _Type_VALUES_TO_NAMES.end()) return it->second;
+  return "UNKNOWN";
 }
 
 void AppendSchema(const vector<SchemaElement>& schema, int level,

Reply via email to