apache/druid · warning · ParseException

Unable to parse [%s] as the intermediateRow resulted in empt

Error message

Unable to parse [%s] as the intermediateRow resulted in empty input row

What it means

JsonNodeReader.parseInputRows throws a Druid ParseException when flattening the intermediate JsonNode produces an empty input row list. This signals the record could not be meaningfully parsed into any row; ParseExceptions are typically counted and the record skipped rather than aborting the task.

Source

Thrown at processing/src/main/java/org/apache/druid/data/input/impl/JsonNodeReader.java:151

  @Override
  protected InputEntity source()
  {
    return source;
  }

  @Override
  protected List<InputRow> parseInputRows(JsonNode intermediateRow) throws ParseException
  {
    if (intermediateRow instanceof ParseExceptionMarkerJsonNode) {
      throw ((ParseExceptionMarkerJsonNode) intermediateRow).getParseException();
    }
    final List<InputRow> inputRows = Collections.singletonList(
        MapInputRowParser.parse(inputRowSchema, flattener.flatten(intermediateRow))
    );

    if (CollectionUtils.isNullOrEmpty(inputRows)) {
      throw new ParseException(
          intermediateRow.toString(),
          "Unable to parse [%s] as the intermediateRow resulted in empty input row",
          intermediateRow.toString()
      );
    }
    return inputRows;
  }

  @Override
  protected List<Map<String, Object>> toMap(JsonNode intermediateRow) throws IOException
  {
    if (intermediateRow instanceof ParseExceptionMarkerJsonNode) {
      throw ((ParseExceptionMarkerJsonNode) intermediateRow).getParseException();
    }
    return Collections.singletonList(
        mapper.readValue(intermediateRow.toString(), new TypeReference<>() {})
    );
  }

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Inspect the logged intermediate row string to see why flattening produced nothing
  2. Fix or remove flattenSpec expressions that produce no columns for such records
  3. Filter or repair upstream records that are null/empty before ingestion
  4. Rely on Druid's parseException reporting (useRowsForSchema / task logs) to skip bad records if skipping is acceptable

Example fix

// before: record {"a":null} with flattenSpec expecting "a.b" -> empty row
// after: fix flattenSpec
"flattenSpec": {"useFieldDiscovery": true, "fields": [{"name":"a","type":"root"}]}
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-validate NDJSON lines before ingestion
for (String line : lines) {
    JsonNode n = objectMapper.readTree(line);
    if (n == null || n.isNull() || (n.isObject() && n.isEmpty())) log.warn("Skipping empty record");
}

Type guard

static boolean isEmptyRecord(JsonNode node) { return node == null || node.isNull() || (node.isContainerNode() && node.isEmpty()); }

Try / catch

try { reader.read(); } catch (ParseException e) { parseMetrics.skipped++; log.warn(e.getMessage()); /* continue; Druid tolerates ParseExceptions up to maxParseExceptions */ }

Prevention

When it happens

Trigger: A JSON record flattens to zero rows — e.g. a null or empty-object record under a flattenSpec that yields no columns, or record filtering that removes everything from a single-record payload.

Common situations: Malformed or null JSON lines inside newline-delimited files; flattenSpec expressions that match nothing; upstream producers emitting empty records or tombstones.

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 apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/23e8e78bae4b3793. Report an issue: GitHub.