apache/beam · error · NullPointerException

Null value at column

Error message

Null value at column 

What it means

convertValueToByteString converts a Row field's value into a ByteString for a Bigtable SetCell. Bigtable cells cannot store null values, so when row.getValue(column) is null the transform throws a NullPointerException identifying the offending column.

Source

Thrown at sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BeamRowToBigtableMutation.java:116

      }
    }

    private Mutation mutation(String family, String column, Row row) {
      return Mutation.newBuilder()
          .setSetCell(
              Mutation.SetCell.newBuilder()
                  .setValue(convertValueToByteString(row, column))
                  .setColumnQualifier(ByteString.copyFromUtf8(column))
                  .setFamilyName(family)
                  .build())
          .build();
    }

    private ByteString convertValueToByteString(Row row, String column) {
      Schema.Field field = row.getSchema().getField(column);
      Object value = row.getValue(column);
      if (value == null) {
        throw new NullPointerException("Null value at column " + column);
      } else {
        return cellValueParser.valueToByteString(value, field.getType());
      }
    }
  }
}

View on GitHub (pinned to 12126d8942)

Solutions

  1. Filter or fill nulls before the transform (e.g. setValue with a default, or Filter.by excluding rows with null target columns).
  2. Skip null columns when building the mutation map so only populated fields become SetCell mutations.
  3. Represent nulls as explicit sentinel values (e.g. empty ByteString or a marker) if they must be stored.

Example fix

// before
Object value = row.getValue(column); // may be null
// after
Object value = row.getValue(column);
if (value == null) {
  return ByteString.EMPTY; // or skip this column entirely
}
Defensive patterns

Strategy: validation

Validate before calling

for (String col : targetColumns) {
  if (row.getValue(col) == null) {
    throw new IllegalArgumentException("Column " + col + " is null; cannot write to Bigtable");
  }
}

Type guard

boolean isStorable(Row row, String column) { return row.getValue(column) != null; }

Try / catch

try { return convertValueToByteString(row, column); } catch (NullPointerException e) { log.warn("Skipping null column {}", column); return null; }

Prevention

When it happens

Trigger: A mutation is built for a column family whose mapped Row column exists in the schema but holds a null value at runtime.

Common situations: Sparse source records where optional columns are null; ETL pipelines writing raw rows without null-filtering; schema fields declared but not populated.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/454e6625914d2594. Report an issue: GitHub.