Add back KuduColumnSchema DataTypeToString

KuduColumnSchema’s DataTypeToString method
was accidentally removed in KUDU-721.

This method/functionality should be added back
to prevent a compatibility break. However, it’s
implimentation has been updated to print based
on the public DataType instead of converting to the
internal type and printing that.

Change-Id: I2bf6879f5ab623366a962c6a3d51efc49978a53c
Reviewed-on: http://gerrit.cloudera.org:8080/9240
Tested-by: Kudu Jenkins
Reviewed-by: Dan Burkert <d...@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/118e8f34
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/118e8f34
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/118e8f34

Branch: refs/heads/master
Commit: 118e8f34c6d72c049e422df827f53341687dd275
Parents: c9e3bd8
Author: Grant Henke <granthe...@gmail.com>
Authored: Wed Feb 7 12:03:32 2018 -0600
Committer: Grant Henke <granthe...@gmail.com>
Committed: Tue Feb 13 21:52:14 2018 +0000

----------------------------------------------------------------------
 src/kudu/client/schema.cc | 28 ++++++++++++++++++++++++++++
 src/kudu/client/schema.h  |  5 +++++
 2 files changed, 33 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/118e8f34/src/kudu/client/schema.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/schema.cc b/src/kudu/client/schema.cc
index c8e5323..8ac73e9 100644
--- a/src/kudu/client/schema.cc
+++ b/src/kudu/client/schema.cc
@@ -558,6 +558,34 @@ Status KuduSchemaBuilder::Build(KuduSchema* schema) {
 // KuduColumnSchema
 ////////////////////////////////////////////////////////////
 
+std::string KuduColumnSchema::DataTypeToString(DataType type) {
+  switch (type) {
+    case INT8:
+      return "INT8";
+    case INT16:
+      return "INT16";
+    case INT32:
+      return "INT32";
+    case INT64:
+      return "INT64";
+    case STRING:
+      return "STRING";
+    case BOOL:
+      return "BOOL";
+    case FLOAT:
+      return "FLOAT";
+    case DOUBLE:
+      return "DOUBLE";
+    case BINARY:
+      return "BINARY";
+    case UNIXTIME_MICROS:
+      return "UNIXTIME_MICROS";
+    case DECIMAL:
+      return "DECIMAL";
+  }
+  LOG(FATAL) << "Unhandled type " << type;
+}
+
 KuduColumnSchema::KuduColumnSchema(const std::string &name,
                                    DataType type,
                                    bool is_nullable,

http://git-wip-us.apache.org/repos/asf/kudu/blob/118e8f34/src/kudu/client/schema.h
----------------------------------------------------------------------
diff --git a/src/kudu/client/schema.h b/src/kudu/client/schema.h
index d6084ca..9163076 100644
--- a/src/kudu/client/schema.h
+++ b/src/kudu/client/schema.h
@@ -189,6 +189,11 @@ class KUDU_EXPORT KuduColumnSchema {
     TIMESTAMP = UNIXTIME_MICROS //!< deprecated, use UNIXTIME_MICROS
   };
 
+  /// @param [in] type
+  ///   Column data type.
+  /// @return String representation of the column data type.
+  static std::string DataTypeToString(DataType type);
+
   /// Construct KuduColumnSchema object as a copy of another object.
   ///
   /// @param [in] other

Reply via email to