{"record":{"id":"2f48cf6c611d498c","repo":"apache/beam","slug":"unknown-precision-this","errorCode":null,"errorMessage":"Unknown precision: \" + this","messagePattern":"Unknown precision: \" \\+ this","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryAvroUtils.java","lineNumber":196,"sourceCode":"    /** Converts an epoch value of this precision to an Instant. */\n    java.time.Instant toInstant(long epochValue) {\n      switch (this) {\n        case MILLISECONDS:\n          return java.time.Instant.ofEpochMilli(epochValue);\n        case MICROSECONDS:\n          {\n            long seconds = Math.floorDiv(epochValue, 1_000_000L);\n            long microsOfSecond = Math.floorMod(epochValue, 1_000_000L);\n            return java.time.Instant.ofEpochSecond(seconds, microsOfSecond * 1_000L);\n          }\n        case NANOSECONDS:\n          {\n            long seconds = Math.floorDiv(epochValue, 1_000_000_000L);\n            long nanosOfSecond = Math.floorMod(epochValue, 1_000_000_000L);\n            return java.time.Instant.ofEpochSecond(seconds, nanosOfSecond);\n          }\n        default:\n          throw new IllegalStateException(\"Unknown precision: \" + this);\n      }\n    }\n  }\n\n  /**\n   * Formats an Instant with minimal fractional second precision. Shows 0, 3, 6, or 9 decimal places\n   * based on actual precision of the value.\n   */\n  @VisibleForTesting\n  @SuppressWarnings(\"JavaInstantGetSecondsGetNano\")\n  static String formatDatetime(java.time.Instant instant) {\n    String dateTime = DATE_TIME_FORMATTER.format(instant);\n    int nanos = instant.getNano();\n\n    if (nanos == 0) {\n      return dateTime;\n    } else if (nanos % 1_000_000 == 0) {\n      return dateTime + String.format(\".%03d\", nanos / 1_000_000);","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryAvroUtils.java#L178-L214","documentation":"BigQueryAvroUtils contains an enum mapping Avro timestamp precision (MILLIS, MICROS, NANOS) to Instant conversion. Its toInstant default arm throws IllegalStateException when the precision enum value has no conversion branch — an internal invariant violation.","triggerScenarios":"Calling toInstant on the precision enum when a new Avro logical type precision is added but the conversion switch is not updated; or reflective/unexpected enum value at runtime.","commonSituations":"Beam version mismatches where an Avro file carries a precision enum value the loaded Beam code does not know; practically rare because the enum set is closed.","solutions":["Upgrade or align Apache Beam versions so code and data precision enums match","Ensure Avro input files only use MILLIS/MICROS/NANOS timestamp precision","Report a bug if a supported precision still hits the default branch"],"exampleFix":"// before\nswitch (precision) { case MILLIS: ...; } // NANOS missing\n// after\nswitch (precision) { case MILLIS: ...; case MICROS: ...; case NANOS: ...; }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { Instant t = precision.toInstant(epochValue); } catch (IllegalStateException e) { /* fall back to millis precision */ }","preventionTips":["Align Avro writer and Beam reader versions","Only use MILLIS/MICROS/NANOS precision in Avro logical types","Round-trip test Avro timestamps through the pipeline"],"tags":["java","apache-beam","avro","timestamp","internal-state"],"backgroundTag":"internal-invariant-violation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}