prestodb/presto · error · ParseError

RowExpression RowExpression

Error message

 RowExpression  RowExpression

What it means

from_json for shared_ptr<RowExpression> reads the subclass discriminator with getSubclassKey; a nlohmann json::parse_error during that read is rethrown as a protocol ParseError with the suffix ' RowExpression RowExpression'. This means the RowExpression JSON was structurally invalid before type dispatch could select a concrete expression class.

Source

Thrown at presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.cpp:232

  }
  if (type == "lambda") {
    j = *std::static_pointer_cast<LambdaDefinitionExpression>(p);
    return;
  }
  if (type == "variable") {
    j = *std::static_pointer_cast<VariableReferenceExpression>(p);
    return;
  }

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

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

  if (type == "call") {
    std::shared_ptr<CallExpression> k = std::make_shared<CallExpression>();
    j.get_to(*k);
    p = std::static_pointer_cast<RowExpression>(k);
    return;
  }
  if (type == "constant") {
    std::shared_ptr<ConstantExpression> k =
        std::make_shared<ConstantExpression>();
    j.get_to(*k);
    p = std::static_pointer_cast<RowExpression>(k);
    return;
  }
  if (type == "special") {
    std::shared_ptr<SpecialFormExpression> k =
        std::make_shared<SpecialFormExpression>();

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Dump and lint the raw JSON fragment for the failing expression
  2. Check coordinator and native worker versions for RowExpression wire-format compatibility
  3. Ensure producers emit the '_type' field within a valid JSON object for every expression
  4. Wrap deserialization in try/catch(ParseError) and log the offending payload for triage

Example fix

// before: malformed expression json
json j = json::parse(fragment); // '@call' garbage -> parse_error -> ParseError
from_json(j, rowExpression);
// after: guard before deserializing
json j = json::parse(fragment);
if (!j.is_object() || !j.contains("_type")) {
  throw std::runtime_error("Bad RowExpression json: " + fragment);
}
from_json(j, rowExpression);
Defensive patterns

Strategy: try-catch

Validate before calling

json j = json::parse(payload);
if (!j.is_object() || !j.contains("_type") || !j["_type"].is_string()) {
  throw std::runtime_error("RowExpression json must be an object with a string _type");
}

Type guard

bool isDeserializableRowExpression(const json& j) {
  return j.is_object() && j.contains("_type") && j["_type"].is_string();
}

Try / catch

try {
  from_json(j, rowExpression);
} catch (const facebook::presto::protocol::ParseError& e) {
  LOG(ERROR) << "RowExpression parse failed: " << e.what() << " payload=" << j.dump();
  throw;
}

Prevention

When it happens

Trigger: Deserializing plan-node expressions where the JSON fragment for the RowExpression is malformed — non-object input, corruption/truncation, or an unexpected shape making getSubclassKey throw parse_error in facebook::presto::protocol::from_json.

Common situations: Truncated or corrupted plan payloads from the coordinator; protocol format drift between Java and native components; malformed test fixtures for expression trees.

Understand the failure class

Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.

Related errors


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