bigquery/WARN/2023_005

Erratic failure with wildcard table

Product: BigQuery
Rule class: WARN - Something that is possibly wrong

Description

In order to execute a GoogleSQL query that uses a wildcard table, BigQuery automatically infers the schema for that table. BigQuery uses the schema for the most recently created table that matches the wildcard as the schema for the wildcard table. Even if you restrict the number of tables that you want to use from the wildcard table using the _TABLE_SUFFIX pseudo column in a WHERE clause, BigQuery uses the schema for the most recently created table that matches the wildcard.

If the schema is inconsistent across the tables matched by the wildcard query, then BigQuery returns an error. This is the case when the columns of the matched tables have different data types, or when the columns which are not present in all of the matched tables cannot be assumed to have a null value.

Remediation

You will need to either rewrite the query, or change the schema in the wildcard tables you are querying, or not use a wildcard.

Further information