prestodb/presto · error · TypeError

no abstract type ColumnHandle

Error message

 no abstract type ColumnHandle 

What it means

This TypeError comes from the to_json overload for std::shared_ptr<ColumnHandle> in the hive protocol serializer. Serialization dispatches on the handle's subclass key; only "hive" (HiveColumnHandle) is handled. Any other discriminator reaches the fallthrough throw, indicating a non-Hive ColumnHandle was serialized through the Hive protocol layer.

Source

Thrown at presto-native-execution/presto_cpp/presto_protocol/connector/hive/presto_protocol_hive.cpp:1559

      "List<HiveType>",
      "hiveTypes");
  from_json_key(
      j, "types", p.types, "HivePartitioningHandle", "List<Type>", "types");
}
} // namespace facebook::presto::protocol::hive
namespace facebook::presto::protocol::hive {
void to_json(json& j, const std::shared_ptr<ColumnHandle>& p) {
  if (p == nullptr) {
    return;
  }
  String type = p->_type;

  if (type == "hive") {
    j = *std::static_pointer_cast<HiveColumnHandle>(p);
    return;
  }

  throw TypeError(type + " no abstract type ColumnHandle ");
}

void from_json(const json& j, std::shared_ptr<ColumnHandle>& p) {
  String type;
  try {
    type = p->getSubclassKey(j);
  } catch (json::parse_error& e) {
    throw ParseError(std::string(e.what()) + " ColumnHandle  ColumnHandle");
  }

  if (type == "hive") {
    std::shared_ptr<HiveColumnHandle> k = std::make_shared<HiveColumnHandle>();
    j.get_to(*k);
    p = std::static_pointer_cast<ColumnHandle>(k);
    return;
  }

  throw TypeError(type + " no abstract type ColumnHandle ");

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Make sure the handle is a HiveColumnHandle with _type == "hive" before serializing in the hive layer
  2. Fix handle construction so the subclass key is populated
  3. Add a to_json branch for the actual tag if hive layer legitimately needs to serialize other handles

Example fix

// before
to_json(j, std::static_pointer_cast<ColumnHandle>(tpcdsHandle)); // hive to_json -> TypeError
// after
auto hive = std::dynamic_pointer_cast<HiveColumnHandle>(handle);
if (!hive) {
  throw TypeError("expected HiveColumnHandle for hive protocol serialization");
}
to_json(j, std::static_pointer_cast<ColumnHandle>(hive));
Defensive patterns

Strategy: type-guard

Validate before calling

std::string tag = handle->getType();
if (tag != "hive") {
  throw TypeError("cannot serialize " + tag + " ColumnHandle via hive protocol");
}

Type guard

bool isHiveColumnHandle(const std::shared_ptr<ColumnHandle>& p) {
  return std::dynamic_pointer_cast<HiveColumnHandle>(p) != nullptr;
}

Try / catch

try {
  to_json(j, columnHandle);
} catch (const TypeError& e) {
  LOG(ERROR) << "Hive ColumnHandle serialization failed: " << e.what();
  throw;
}

Prevention

When it happens

Trigger: Calling to_json on a shared_ptr<ColumnHandle> whose getSubclassKey() is not "hive" — e.g. an ArrowFlightColumnHandle or TpcdsColumnHandle passed into presto_protocol_hive.cpp's serializer.

Common situations: Using a Hive table scan plan with handles produced by another connector; copies of plans where _type was not preserved; tests constructing base ColumnHandle mocks without setting the discriminator.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/54b286c1b1ee2691. Report an issue: GitHub.