You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by em...@apache.org on 2019/05/17 18:43:18 UTC

[arrow] 01/01: Add ToString method to ColumnDescripotor

This is an automated email from the ASF dual-hosted git repository.

emkornfield pushed a commit to branch add_debug_string
in repository https://gitbox.apache.org/repos/asf/arrow.git

commit 9568a67448d44145187309e85e630987ee49ec50
Author: Micah Kornfield <mi...@google.com>
AuthorDate: Fri May 17 11:42:55 2019 -0700

    Add ToString method to ColumnDescripotor
---
 cpp/src/parquet/schema.cc | 27 ++++++++++++++++++++++++---
 cpp/src/parquet/schema.h  |  2 ++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/cpp/src/parquet/schema.cc b/cpp/src/parquet/schema.cc
index 0a5668d..9206aba 100644
--- a/cpp/src/parquet/schema.cc
+++ b/cpp/src/parquet/schema.cc
@@ -16,17 +16,15 @@
 // under the License.
 
 #include "parquet/schema.h"
-#include "parquet/schema-internal.h"
 
 #include <algorithm>
 #include <cstring>
 #include <memory>
 #include <string>
 #include <utility>
-
 #include "arrow/util/logging.h"
-
 #include "parquet/exception.h"
+#include "parquet/schema-internal.h"
 #include "parquet/thrift.h"
 
 using parquet::format::SchemaElement;
@@ -746,6 +744,29 @@ std::string SchemaDescriptor::ToString() const {
   return ss.str();
 }
 
+std::string ColumnDescriptor::ToString() const {
+  std::ostringstream ss;
+  ss << "column descriptor = {" << std::endl
+     << "  name: " << name() << std::endl
+     << "  path: " << path()->ToDotString() << std::endl
+     << "  physical_type: " << TypeToString(physical_type()) << std::endl
+     << "  logical_type: " << LogicalTypeToString(logical_type()) << std::endl
+     << "  max_definition_level: " << max_definition_level() << std::endl
+     << "  max_repetition_level: " << max_repetition_level() << std::endl;
+
+  if (physical_type() == ::parquet::Type::FIXED_LEN_BYTE_ARRAY) {
+    ss << "  length: " << type_length() << std::endl;
+  }
+
+  if (logical_type() == parquet::LogicalType::DECIMAL) {
+    ss << "  precision: " << type_precision() << std::endl
+       << "  scale: " << type_scale() << std::endl;
+  }
+
+  ss << "}";
+  return ss.str();
+}
+
 int ColumnDescriptor::type_scale() const {
   return primitive_node_->decimal_metadata().scale;
 }
diff --git a/cpp/src/parquet/schema.h b/cpp/src/parquet/schema.h
index 76920c0..62cf95c 100644
--- a/cpp/src/parquet/schema.h
+++ b/cpp/src/parquet/schema.h
@@ -353,6 +353,8 @@ class PARQUET_EXPORT ColumnDescriptor {
 
   const schema::NodePtr& schema_node() const { return node_; }
 
+  std::string ToString() const;
+
   int type_length() const;
 
   int type_precision() const;