apache/beam · error · RuntimeException

Unable to create table.

Error message

Unable to create table.

What it means

SnowflakeBatchServiceImpl's createTableIfNotExists found the table missing (checkResultIfTableExists returned false) and attempted CREATE TABLE, but the CREATE statement threw a SQLException. The RuntimeException wraps that driver error.

Solutions

  1. Read the wrapped SQLException cause for Snowflake's exact error message/code.
  2. Grant CREATE TABLE on the target schema to the connecting role: GRANT CREATE TABLE ON SCHEMA <db>.<schema> TO ROLE <role>.
  3. Verify every column name/type in your SnowflakeTableSchema is valid Snowflake DDL.
  4. Confirm the database/schema in the SnowflakeServiceConfig exists and the session is using it.

Example fix

// before
new SnowflakeTableSchema().addVarCharColumn("ts").addIntColumn("count") // ok
// after (fix privilege, then rerun)
// GRANT CREATE TABLE ON SCHEMA mydb.public TO ROLE beam_role;
Defensive patterns

Strategy: try-catch

Validate before calling

// Grant check before run
// SHOW GRANTS ON SCHEMA <db>.<schema>; -- confirm CREATE TABLE privilege for your role

Try / catch

try { pipeline.run(); }
catch (RuntimeException e) {
  if ("Unable to create table.".equals(e.getMessage())) {
    java.sql.SQLException cause = (java.sql.SQLException) e.getCause(); // log Snowflake error code/message
  }
}

Prevention

When it happens

Trigger: createDisposition=CREATE_IF_NEEDED with a tableSchema, the table does not exist, and Snowflake rejects the CREATE TABLE statement — syntax generated from SnowflakeTableSchema, insufficient privileges, or connection failure.

Common situations: Role lacks CREATE TABLE privilege on the schema; malformed SnowflakeTableSchema entries (bad column types); schema/database names wrong or not in the search path.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/aa3eea1035a3153e. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/services/SnowflakeBatchServiceImpl.java:248

      String schema,
      String table,
      SnowflakeTableSchema tableSchema)
      throws SQLException {
    String query =
        String.format(
            "SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_catalog = '%s' AND table_schema = '%s' AND table_name = '%s');",
            database.toUpperCase(), schema.toUpperCase(), table.toUpperCase());

    runConnectionWithStatement(
        dataSource,
        query,
        resultSet -> {
          assert resultSet != null;
          if (!checkResultIfTableExists(resultSet)) {
            try {
              createTable(dataSource, table, tableSchema);
            } catch (SQLException e) {
              throw new RuntimeException("Unable to create table.", e);
            }
          }
        });
  }

  private static boolean checkResultIfTableExists(ResultSet resultSet) {
    try {
      if (resultSet.next()) {
        return checkIfResultIsTrue(resultSet);
      } else {
        throw new RuntimeException("Unable run pipeline with CREATE IF NEEDED - no response.");
      }
    } catch (SQLException e) {
      throw new RuntimeException("Unable run pipeline with CREATE IF NEEDED disposition.", e);
    }
  }

  private void createTable(DataSource dataSource, String table, SnowflakeTableSchema tableSchema)

View on GitHub (pinned to 12126d8942)