Skip to content

Commit

Permalink
Add macro to convert ParquetException to Status
Browse files Browse the repository at this point in the history
  • Loading branch information
xhochy committed May 1, 2016
1 parent 9c5b085 commit e3aa261
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cpp/src/arrow/parquet/schema.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
#include <vector>

#include "parquet/api/schema.h"
#include "parquet/exception.h"

#include "arrow/types/decimal.h"
#include "arrow/types/string.h"
#include "arrow/util/status.h"

using parquet::ParquetException;
using parquet::Repetition;
using parquet::schema::Node;
using parquet::schema::NodePtr;
Expand All @@ -39,6 +41,11 @@ namespace arrow {

namespace parquet {

#define PARQUET_CATCH_NOT_OK(s) \
try { \
(s); \
} catch (const ParquetException& e) { return Status::Invalid(e.what()); }

const auto BOOL = std::make_shared<BooleanType>();
const auto UINT8 = std::make_shared<UInt8Type>();
const auto INT32 = std::make_shared<Int32Type>();
Expand Down Expand Up @@ -300,7 +307,7 @@ Status ToParquetSchema(

NodePtr schema = GroupNode::Make("schema", Repetition::REPEATED, nodes);
*out = std::make_shared<::parquet::SchemaDescriptor>();
(*out)->Init(schema);
PARQUET_CATCH_NOT_OK((*out)->Init(schema));

return Status::OK();
}
Expand Down

0 comments on commit e3aa261

Please sign in to comment.