deeplearning4j/deeplearning4j · error · IllegalStateException
columnNumber == -1 -> setInputSchema not called?
Error message
columnNumber == -1 -> setInputSchema not called?
What it means
BaseColumnTransform caches the index of its target column when setInputSchema(...) is called. This IllegalStateException in transform(Schema) means that method was never invoked, so columnNumber is still its -1 sentinel. It is an internal lifecycle-ordering check: the transform must know its input schema before it can transform a schema.
Solutions
- Call transform.setInputSchema(inputSchema) before invoking transform(Schema) or map(...)
- Build the transform through TransformProcess.Builder, which sets the schema automatically
- If constructing from serialized config, restore the schema binding before use
Example fix
// before myTransform.transform(schema); // after myTransform.setInputSchema(schema); myTransform.transform(schema);
Defensive patterns
Strategy: validation
Validate before calling
// guard before use if (transform.getInputSchema() == null) transform.setInputSchema(schema);
Try / catch
try { return transform.transform(schema); } catch (IllegalStateException e) { throw new IllegalStateException("setInputSchema must be called before transform", e); } Prevention
- Always build transforms via TransformProcess.Builder
- Call setInputSchema immediately after constructing a BaseColumnTransform
- Never use transforms deserialized from config without re-binding the schema
When it happens
Trigger: Calling transform(Schema) (or map/mapSequence flows that depend on it) on a BaseColumnTransform subclass constructed manually without first calling setInputSchema(schema). Typical when building transforms programmatically and skipping the schema step.
Common situations: Hand-rolling a transform instead of using a TransformProcess.Builder (which wires setInputSchema automatically), or deserializing/constructing a transform from config and forgetting the schema binding step.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Cannot execute transform: input writables list length
- Cannot apply numerical column comparator on column of type
- Cannot convert non-string type
- Cannot convert non-string type
- Cannot execute transform: input writables list length (" +…
AI-assisted analysis of deeplearning4j/deeplearning4j@4c22ac5fe4 (2026-09-07).
Data as JSON: /api/errors/571ea54bc1edc93b.
Report an issue: GitHub.
Appendix: source
Thrown at datavec/datavec-api/src/main/java/org/datavec/api/transform/transform/BaseColumnTransform.java:57
protected String columnName;
protected int columnNumber = -1;
private static final long serialVersionUID = 0L;
public BaseColumnTransform(String columnName) {
this.columnName = columnName;
}
@Override
public void setInputSchema(Schema inputSchema) {
this.inputSchema = inputSchema;
columnNumber = inputSchema.getIndexOfColumn(columnName);
}
@Override
public Schema transform(Schema schema) {
if (columnNumber == -1)
throw new IllegalStateException("columnNumber == -1 -> setInputSchema not called?");
List<ColumnMetaData> oldMeta = schema.getColumnMetaData();
List<ColumnMetaData> newMeta = new ArrayList<>(oldMeta.size());
Iterator<ColumnMetaData> typesIter = oldMeta.iterator();
int i = 0;
while (typesIter.hasNext()) {
ColumnMetaData t = typesIter.next();
if (i++ == columnNumber) {
newMeta.add(getNewColumnMetaData(t.getName(), t));
} else {
newMeta.add(t);
}
}
return schema.newSchema(newMeta);
}
View on GitHub (pinned to 4c22ac5fe4)