{"record":{"id":"cbea44084d5b9604","repo":"apache/beam","slug":"unable-run-pipeline-with-create-if-needed-no-response","errorCode":null,"errorMessage":"Unable run pipeline with CREATE IF NEEDED - no response.","messagePattern":"Unable run pipeline with CREATE IF NEEDED - no response\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/services/SnowflakeBatchServiceImpl.java","lineNumber":259,"sourceCode":"        query,\n        resultSet -> {\n          assert resultSet != null;\n          if (!checkResultIfTableExists(resultSet)) {\n            try {\n              createTable(dataSource, table, tableSchema);\n            } catch (SQLException e) {\n              throw new RuntimeException(\"Unable to create table.\", e);\n            }\n          }\n        });\n  }\n\n  private static boolean checkResultIfTableExists(ResultSet resultSet) {\n    try {\n      if (resultSet.next()) {\n        return checkIfResultIsTrue(resultSet);\n      } else {\n        throw new RuntimeException(\"Unable run pipeline with CREATE IF NEEDED - no response.\");\n      }\n    } catch (SQLException e) {\n      throw new RuntimeException(\"Unable run pipeline with CREATE IF NEEDED disposition.\", e);\n    }\n  }\n\n  private void createTable(DataSource dataSource, String table, SnowflakeTableSchema tableSchema)\n      throws SQLException {\n    checkArgument(\n        tableSchema != null,\n        \"The CREATE_IF_NEEDED disposition requires schema if table doesn't exists\");\n    String query = String.format(\"CREATE TABLE %s (%s);\", table, tableSchema.sql());\n    runConnectionWithStatement(dataSource, query, null);\n  }\n\n  private static boolean checkIfResultIsTrue(ResultSet resultSet) throws SQLException {\n    int columnId = 1;\n    return resultSet.getBoolean(columnId);","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/services/SnowflakeBatchServiceImpl.java#L241-L277","documentation":"checkResultIfTableExists expects the SHOW TABLES-style result set for the CREATE IF NEEDED disposition to return at least one row; an empty result set means the table-existence probe produced no answer, so Beam aborts rather than guessing. Unlike an empty-rowset meaning 'table missing', here the overall query yielded nothing interpretable.","triggerScenarios":"Running createTableIfNotExists (CREATE_IF_NEEDED disposition) when the existence-check statement returns a result set with no rows at all — resultSet.next() is false on the first call.","commonSituations":"Custom SnowflakeServiceConfig / StatementExecutionSupplier returning malformed or empty results; driver returning an unexpected result shape for the SHOW-object query; misconfigured database/schema so the probe targets a non-existent container and the driver swallows errors into an empty result.","solutions":["Check your custom StatementExecutionSupplier/implementation is returning the raw result set of the existence query, not a pre-consumed or empty one.","Verify database and schema names in the config are correct and exist.","Update the Snowflake JDBC driver; some versions changed SHOW result-set behavior.","Use a simpler existence probe manually (SELECT 1 FROM information_schema.tables WHERE ...) to compare behavior."],"exampleFix":"// before: supplier returns empty ResultSet\nresult -> statement.executeQuery(\"SHOW OBJECTS IN missing_db.public\")\n// after: ensure target exists\nresult -> statement.executeQuery(\"SHOW OBJECTS IN mydb.public\")","handlingStrategy":"validation","validationCode":"// Validate your StatementExecutionSupplier returns the raw result set\n// ResultSet rs = supplier.apply(statement); assert rs.getMetaData().getColumnCount() > 0;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never consume or close the ResultSet inside a custom StatementExecutionSupplier.","Confirm database/schema names in SnowflakeServiceConfig exist.","Keep the Snowflake JDBC driver up to date."],"tags":["snowflake","result-set","database","pipeline"],"backgroundTag":"empty-result-set","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"}