{"record":{"id":"69e310f4c39b6cba","repo":"apache/beam","slug":"s-is-not-supported-in-bit-and","errorCode":null,"errorMessage":"[%s] is not supported in BIT_AND","messagePattern":"\\[(.+?)\\] is not supported in BIT_AND","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/transform/BeamBuiltinAggregations.java","lineNumber":244,"sourceCode":"      default:\n        throw new UnsupportedOperationException(\n            String.format(\"[%s] is not supported in AVG\", fieldType));\n    }\n  }\n\n  static CombineFn createBitOr(Schema.FieldType fieldType) {\n    if (fieldType.getTypeName() == TypeName.INT64) {\n      return new BitOr();\n    }\n    throw new UnsupportedOperationException(\n        String.format(\"[%s] is not supported in BIT_OR\", fieldType));\n  }\n\n  static CombineFn createBitAnd(Schema.FieldType fieldType) {\n    if (fieldType.getTypeName() == TypeName.INT64) {\n      return new BitAnd();\n    }\n    throw new UnsupportedOperationException(\n        String.format(\"[%s] is not supported in BIT_AND\", fieldType));\n  }\n\n  public static CombineFn createBitXOr(Schema.FieldType fieldType) {\n    if (fieldType.getTypeName() == TypeName.INT64) {\n      return new BitXOr();\n    }\n    throw new UnsupportedOperationException(\n        String.format(\"[%s] is not supported in BIT_XOR\", fieldType));\n  }\n\n  static class CustMax<T extends Comparable<T>> extends Combine.BinaryCombineFn<T> {\n    @Override\n    public T apply(T left, T right) {\n      return (right == null || right.compareTo(left) < 0) ? left : right;\n    }\n  }\n","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/transform/BeamBuiltinAggregations.java#L226-L262","documentation":"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.","triggerScenarios":"Calling BeamBuiltinAggregations.createBitAnd(fieldType) with TypeName != INT64 — commonly an INT32 (INTEGER) column or a non-numeric column used in SELECT BIT_AND(col).","commonSituations":"BIT_AND applied to INT32 bitmask columns; queries copied from engines that permit BIT_AND on any integer width.","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."],"exampleFix":"// before\nCombineFn fn = BeamBuiltinAggregations.createBitAnd(Schema.FieldType.INT32); // throws\n\n// after\nCombineFn fn = BeamBuiltinAggregations.createBitAnd(Schema.FieldType.INT64);","handlingStrategy":"validation","validationCode":"if (fieldType.getTypeName() != Schema.TypeName.INT64) {\n  throw new IllegalArgumentException(\"BIT_AND requires INT64, got \" + fieldType);\n}","typeGuard":"boolean bitAndSupported(Schema.FieldType t) {\n  return t.getTypeName() == Schema.TypeName.INT64;\n}","tryCatchPattern":"try {\n  CombineFn fn = BeamBuiltinAggregations.createBitAnd(fieldType);\n} catch (UnsupportedOperationException e) {\n  // re-plan with CAST(col AS BIGINT)\n}","preventionTips":["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."],"tags":["beam-sql","unsupported-type","bitwise","java"],"backgroundTag":"unsupported-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}