Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAyd committed Jan 30, 2024
1 parent 5106d90 commit 61bcec6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 32 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ repos:
hooks:
- id: clang-format
args: [--style=LLVM]
files: 'pantab/src/(.*)'
60 changes: 29 additions & 31 deletions src/pantab/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,36 +310,35 @@ static auto GetArrowTypeFromHyper(const hyperapi::SqlType &sqltype)
}

static auto SetSchemaTypeFromHyperType(struct ArrowSchema *schema,
const hyperapi::SqlType& sqltype) -> void {
switch (sqltype.getTag()) {
case hyperapi::TypeTag::TimestampTZ:
if (ArrowSchemaSetTypeDateTime(schema,
NANOARROW_TYPE_TIMESTAMP,
NANOARROW_TIME_UNIT_MICRO, "UTC")) {
throw std::runtime_error(
"ArrowSchemaSetDateTime failed for TimestampTZ type");
}
break;
case hyperapi::TypeTag::Timestamp:
if (ArrowSchemaSetTypeDateTime(schema,
NANOARROW_TYPE_TIMESTAMP,
NANOARROW_TIME_UNIT_MICRO, nullptr)) {
throw std::runtime_error(
"ArrowSchemaSetDateTime failed for Timestamp type");
}
break;
case hyperapi::TypeTag::Time:
if (ArrowSchemaSetTypeDateTime(schema, NANOARROW_TYPE_TIME64,
NANOARROW_TIME_UNIT_MICRO, nullptr)) {
throw std::runtime_error("ArrowSchemaSetDateTime failed for Time type");
}
break;
default:
const enum ArrowType arrow_type = GetArrowTypeFromHyper(sqltype);
if (ArrowSchemaSetType(schema, arrow_type)) {
throw std::runtime_error("ArrowSchemaSetType failed");
}
const hyperapi::SqlType &sqltype)
-> void {
switch (sqltype.getTag()) {
case hyperapi::TypeTag::TimestampTZ:
if (ArrowSchemaSetTypeDateTime(schema, NANOARROW_TYPE_TIMESTAMP,
NANOARROW_TIME_UNIT_MICRO, "UTC")) {
throw std::runtime_error(
"ArrowSchemaSetDateTime failed for TimestampTZ type");
}
break;
case hyperapi::TypeTag::Timestamp:
if (ArrowSchemaSetTypeDateTime(schema, NANOARROW_TYPE_TIMESTAMP,
NANOARROW_TIME_UNIT_MICRO, nullptr)) {
throw std::runtime_error(
"ArrowSchemaSetDateTime failed for Timestamp type");
}
break;
case hyperapi::TypeTag::Time:
if (ArrowSchemaSetTypeDateTime(schema, NANOARROW_TYPE_TIME64,
NANOARROW_TIME_UNIT_MICRO, nullptr)) {
throw std::runtime_error("ArrowSchemaSetDateTime failed for Time type");
}
break;
default:
const enum ArrowType arrow_type = GetArrowTypeFromHyper(sqltype);
if (ArrowSchemaSetType(schema, arrow_type)) {
throw std::runtime_error("ArrowSchemaSetType failed");
}
}
}

static auto ReleaseArrowStream(void *ptr) noexcept -> void {
Expand All @@ -349,7 +348,6 @@ static auto ReleaseArrowStream(void *ptr) noexcept -> void {
}
}


///
/// read_from_hyper_query is slightly different than read_from_hyper_table
/// because the former detects a schema from the hyper Result object
Expand Down Expand Up @@ -377,7 +375,7 @@ auto read_from_hyper_query(const std::string &path, const std::string &query)
for (size_t i = 0; i < column_count; i++) {
const auto column = resultSchema.getColumn(i);
auto name = column.getName().getUnescaped();
const auto& [elem, did_insert] = name_counter.emplace(name, 0);
const auto &[elem, did_insert] = name_counter.emplace(name, 0);
if (!did_insert) {
name = name + "_" + std::to_string(elem->second);
}
Expand Down

0 comments on commit 61bcec6

Please sign in to comment.