{"record":{"id":"ac8f656b84453c9d","repo":"apache/beam","slug":"unsupported-schema-specified-for-pubsub-source-in-create","errorCode":null,"errorMessage":"Unsupported schema specified for Pubsub source in CREATE TABLE.CREATE TABLE for Pubsub topic must not be null","messagePattern":"Unsupported schema specified for Pubsub source in CREATE TABLE\\.CREATE TABLE for Pubsub topic must not be null","errorType":"validation","errorClass":"InvalidSchemaException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/PubsubSchemaIOProvider.java","lineNumber":158,"sourceCode":"    validateConfigurationSchema(configuration);\n    validateDlq(configuration.getString(\"deadLetterQueue\"));\n    validateDataSchema(dataSchema);\n    return new PubsubSchemaIO(location, configuration, checkArgumentNotNull(dataSchema));\n  }\n\n  @Override\n  public boolean requiresDataSchema() {\n    return true;\n  }\n\n  @Override\n  public PCollection.IsBounded isBounded() {\n    return PCollection.IsBounded.UNBOUNDED;\n  }\n\n  private void validateDataSchema(@Nullable Schema schema) {\n    if (schema == null) {\n      throw new InvalidSchemaException(\n          \"Unsupported schema specified for Pubsub source in CREATE TABLE.\"\n              + \"CREATE TABLE for Pubsub topic must not be null\");\n    }\n    if (!PubsubSchemaIO.fieldPresent(schema, TIMESTAMP_FIELD, FieldType.DATETIME)) {\n      throw new InvalidSchemaException(\n          \"Unsupported schema specified for Pubsub source in CREATE TABLE.\"\n              + \"CREATE TABLE for Pubsub topic must include at least 'event_timestamp' field of \"\n              + \"type 'TIMESTAMP'\");\n    }\n  }\n\n  private void validateDlq(@Nullable String deadLetterQueue) {\n    if (deadLetterQueue != null && deadLetterQueue.isEmpty()) {\n      throw new InvalidConfigurationException(\"Dead letter queue topic name is not specified\");\n    }\n  }\n\n  private void validateConfigurationSchema(Row configuration) {","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/PubsubSchemaIOProvider.java#L140-L176","documentation":"PubsubSchemaIOProvider.from() validates the data schema supplied in a CREATE TABLE statement via validateDataSchema(). A null schema is rejected with an InvalidSchemaException, because a Pubsub table mapping requires an explicit schema to map message fields.","triggerScenarios":"Executing a CREATE TABLE DDL for a Pubsub table (e.g. via Beam SQL / Sqlline / Calcite) without a schema, so the provider's from() receives schema == null and calls validateDataSchema(null).","commonSituations":"Writing CREATE TABLE without a column list; relying on schema auto-discovery that the SQL provider does not perform; programmatic table config with a null schema field.","solutions":["Add a schema (column list with types) to the CREATE TABLE statement for the Pubsub table.","Include the required 'event_timestamp' TIMESTAMP field in that schema (also checked by the same validator).","If using the Pubsub schema service instead, go through the SchemaTransform path rather than CREATE TABLE, which requires an explicit schema."],"exampleFix":"-- before\nCREATE TABLE pubsub_table ... WITH OPTIONS (...); -- no schema\n-- after\nCREATE TABLE pubsub_table (payload VARCHAR, event_timestamp TIMESTAMP) ... WITH OPTIONS (...);","handlingStrategy":"validation","validationCode":"if (tableSchema == null) { throw new IllegalArgumentException(\"CREATE TABLE for a Pubsub source must declare a non-null schema\"); }","typeGuard":null,"tryCatchPattern":"try { ioProvider.from(tableConfig); } catch (InvalidSchemaException e) { if (e.getMessage().contains(\"must not be null\")) { /* add column list to CREATE TABLE */ } throw e; }","preventionTips":["Always include an explicit column list in CREATE TABLE statements for Pubsub sources.","Do not rely on schema auto-discovery — the SQL Pubsub provider requires an explicit schema."],"tags":["java","apache-beam","pubsub","sql","schema"],"backgroundTag":"schema-validation-failed","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"}