apache/beam · error · UnsupportedOperationException
[ ] is not supported in BIT_AND
Error message
[%s] is not supported in BIT_AND
What it means
createBitAnd implements the BIT_AND aggregate, restricted to exactly INT64 fields. Any other Schema.FieldType TypeName causes an immediate UnsupportedOperationException. Like BIT_OR there is no fallback path.
Solutions
- Cast the column to BIGINT in SQL before BIT_AND.
- Declare the source column as INT64 in the schema.
- Provide a custom Combine.BinaryCombineFn<Integer> with & for INT32 support.
Example fix
// before CombineFn fn = BeamBuiltinAggregations.createBitAnd(Schema.FieldType.INT32); // throws // after CombineFn fn = BeamBuiltinAggregations.createBitAnd(Schema.FieldType.INT64);
Defensive patterns
Strategy: validation
Validate before calling
if (fieldType.getTypeName() != Schema.TypeName.INT64) {
throw new IllegalArgumentException("BIT_AND requires INT64, got " + fieldType);
} Type guard
boolean bitAndSupported(Schema.FieldType t) {
return t.getTypeName() == Schema.TypeName.INT64;
} Try / catch
try {
CombineFn fn = BeamBuiltinAggregations.createBitAnd(fieldType);
} catch (UnsupportedOperationException e) {
// re-plan with CAST(col AS BIGINT)
} Prevention
- Use BIGINT columns for bitwise aggregates.
- Cast INT32 flags to BIGINT in SQL: CAST(flags AS BIGINT).
- Add schema-level assertions that flag columns are INT64.
When it happens
Trigger: Calling BeamBuiltinAggregations.createBitAnd(fieldType) with TypeName != INT64 — commonly an INT32 (INTEGER) column or a non-numeric column used in SELECT BIT_AND(col).
Common situations: BIT_AND applied to INT32 bitmask columns; queries copied from engines that permit BIT_AND on any integer width.
Related errors
- [ ] is not supported in BIT_OR
- [ ] is not supported in BIT_XOR
- [ ] is not supported in AVG
- [ ] is not supported in MAX
- [ ] is not supported in MIN
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/69e310f4c39b6cba.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/transform/BeamBuiltinAggregations.java:244
default:
throw new UnsupportedOperationException(
String.format("[%s] is not supported in AVG", fieldType));
}
}
static CombineFn createBitOr(Schema.FieldType fieldType) {
if (fieldType.getTypeName() == TypeName.INT64) {
return new BitOr();
}
throw new UnsupportedOperationException(
String.format("[%s] is not supported in BIT_OR", fieldType));
}
static CombineFn createBitAnd(Schema.FieldType fieldType) {
if (fieldType.getTypeName() == TypeName.INT64) {
return new BitAnd();
}
throw new UnsupportedOperationException(
String.format("[%s] is not supported in BIT_AND", fieldType));
}
public static CombineFn createBitXOr(Schema.FieldType fieldType) {
if (fieldType.getTypeName() == TypeName.INT64) {
return new BitXOr();
}
throw new UnsupportedOperationException(
String.format("[%s] is not supported in BIT_XOR", fieldType));
}
static class CustMax<T extends Comparable<T>> extends Combine.BinaryCombineFn<T> {
@Override
public T apply(T left, T right) {
return (right == null || right.compareTo(left) < 0) ? left : right;
}
}
View on GitHub (pinned to 12126d8942)