risingwavelabs/risingwave · error

The database name `{}` in the FROM clause is not included in

Error message

The database name `{}` in the FROM clause is not included in the database name `{}` in source definition

What it means

After splitting the FROM-clause table name into `db.table` for a MySQL CDC source, the code verifies that the database prefix appears among the (comma-separated) names declared in the source's `database.name` option. A mismatch means the FROM clause references a database the source is not configured to read, and the error names both values.

Source

Thrown at src/frontend/src/handler/create_table.rs:1017

        .get("database.name")
        .ok_or_else(|| anyhow!("The source with properties does not contain 'database.name'"))?
        .as_str();
    let mut with_options = source_with_properties.clone();
    if let Some(connector) = source_with_properties.get(UPSTREAM_SOURCE_KEY) {
        match connector.as_str() {
            MYSQL_CDC_CONNECTOR => {
                // MySQL doesn't allow '.' in database name and table name, so we can split the
                // external table name by '.' to get the table name
                let (db_name, table_name) = external_table_name.split_once('.').ok_or_else(|| {
                    anyhow!("The upstream table name must contain database name prefix, e.g. 'database.table'")
                })?;
                // We allow multiple database names in the source definition
                if !source_database_name
                    .split(',')
                    .map(|s| s.trim())
                    .any(|name| name == db_name)
                {
                    return Err(anyhow!(
                        "The database name `{}` in the FROM clause is not included in the database name `{}` in source definition",
                        db_name,
                        source_database_name
                    ).into());
                }
                with_options.insert(DATABASE_NAME_KEY.into(), db_name.into());
                with_options.insert(TABLE_NAME_KEY.into(), table_name.into());
                // Return original external_table_name unchanged for MySQL
                return Ok((with_options, external_table_name));
            }
            POSTGRES_CDC_CONNECTOR => {
                let (schema_name, table_name) =
                    parse_postgres_cdc_external_table_name(&external_table_name)?;

                // insert 'schema.name' into connect properties
                with_options.insert(SCHEMA_NAME_KEY.into(), schema_name);
                with_options.insert(TABLE_NAME_KEY.into(), table_name);
                // Return original external_table_name unchanged for Postgres

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Change the FROM-clause prefix to a database listed in the source's `database.name`, e.g. `TABLE 'dbA.orders'`.
  2. Or recreate the source with `database.name` including the desired database (comma-separated for several).
  3. Confirm the exact upstream database name case-sensitively (MySQL is case-sensitive depending on platform).

Example fix

-- before (source has database.name='dbA')
CREATE TABLE t FROM mysql_src TABLE 'dbB.orders';
-- after
CREATE TABLE t FROM mysql_src TABLE 'dbA.orders';
Defensive patterns

Strategy: validation

Validate before calling

fn db_in_source(from_db: &str, source_db: &str) -> bool {
    source_db.split(',').map(|s| s.trim()).any(|n| n == from_db)
}

Prevention

When it happens

Trigger: `CREATE TABLE ... FROM mysql_src TABLE 'dbB.orders'` where the source was defined with `'database.name' = 'dbA'` (or a list not containing dbB); also triggered during table replacement.

Common situations: Typos in the database prefix; sources declared with multiple databases (`'dbA,dbB'`) where the user references a database omitted from the list; renamed databases on the upstream.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11). Data as JSON: /api/errors/25e4644b30097f44. Report an issue: GitHub.