You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BigQuery schema sync fails when ORDINAL_POSITION is NULL #21217
Bytebase fails to sync the database schema from Google BigQuery when ORDINAL_POSITION returned by BigQuery metadata is NULL.
The schema sync fails completely with the following error:
failed to sync database schema for database "xxx": bigquery: NULL cannot be assigned to field OrdinalPosition of type int32
It looks like the BigQuery schema introspection code expects OrdinalPosition to always be a non-null int32, while BigQuery can return NULL for this field for some metadata entries.
Steps to reproduce
1/ Add a Google BigQuery instance to Bytebase.
2/ Connect to a project containing the xx dataset/database.
3/ Trigger Sync database schema.
4/ Bytebase starts querying the BigQuery metadata.
5/ Schema synchronization fails when BigQuery returns a NULL value for ORDINAL_POSITION.
Expected behavior
Bytebase should successfully synchronize the BigQuery schema even when ORDINAL_POSITION is NULL.
A nullable ordinal position returned by BigQuery metadata should not cause the entire database schema sync to fail.
Thanks for the detailed report — the error is reproducible and I've traced it to how we decode ordinal_position from INFORMATION_SCHEMA.COLUMNS. BigQuery returns NULL there for pseudo columns, and we assume a non-null integer.
Before we settle on a fix, could you run these two queries against the dataset that fails? They only read metadata — no table data — and the first is aggregated so it won't reveal your table names.
1. Which columns have a NULL ordinal position, and what kind of object are they on:
SELECTt.table_type,
c.column_name,
c.data_type,
c.is_hidden,
c.is_system_defined,
c.is_partitioning_column,
COUNT(*) AS column_count
FROM`PROJECT_ID`.DATASET_ID.INFORMATION_SCHEMA.COLUMNS AS c
LEFT JOIN`PROJECT_ID`.DATASET_ID.INFORMATION_SCHEMA.TABLES AS t
ONc.table_catalog=t.table_catalogANDc.table_schema=t.table_schemaANDc.table_name=t.table_nameWHEREc.ordinal_position IS NULLGROUP BY1, 2, 3, 4, 5, 6ORDER BY column_count DESC;
2. What object types the dataset contains:
SELECT table_type, COUNT(*) AS table_count
FROM`PROJECT_ID`.DATASET_ID.INFORMATION_SCHEMA.TABLES
GROUP BY table_type
ORDER BY table_count DESC;
Replace PROJECT_ID and DATASET_ID with the dataset that fails to sync. The first query's output is what we need most — it tells us whether this is coming from ingestion-time partitioning (_PARTITIONTIME / _PARTITIONDATE) or from external tables (_FILE_NAME), which points at different fixes.
could you run these two queries against the dataset that fails? They only read metadata — no table data — and the first is aggregated so it won't reveal your table names.
Thanks for running those queries — that confirms this is ingestion-time partitioning, not external-table _FILE_NAME.
_PARTITIONTIME is a hidden/system-defined pseudo column (is_hidden = YES, is_system_defined = YES, is_partitioning_column = YES) with ordinal_position IS NULL. That's the case #21220 already handles: schema sync now excludes hidden columns (WHERE is_hidden = 'NO') and skips any remaining NULL ordinals, so these two pseudo columns no longer abort the whole database sync.
Activity
tuyndoan commentedon Aug 21, 2026
Opened a fix in #21220 — use
bigquery.NullInt64forOrdinalPositionso NULL from BigQuery no longer fails schema sync.d-bytebase commentedon Aug 21, 2026
Thanks for the detailed report — the error is reproducible and I've traced it to how we decode
ordinal_positionfromINFORMATION_SCHEMA.COLUMNS. BigQuery returns NULL there for pseudo columns, and we assume a non-null integer.Before we settle on a fix, could you run these two queries against the dataset that fails? They only read metadata — no table data — and the first is aggregated so it won't reveal your table names.
1. Which columns have a NULL ordinal position, and what kind of object are they on:
2. What object types the dataset contains:
Replace
PROJECT_IDandDATASET_IDwith the dataset that fails to sync. The first query's output is what we need most — it tells us whether this is coming from ingestion-time partitioning (_PARTITIONTIME/_PARTITIONDATE) or from external tables (_FILE_NAME), which points at different fixes.mangareader commentedon Aug 22, 2026
tuyndoan commentedon Aug 24, 2026
Thanks for running those queries — that confirms this is ingestion-time partitioning, not external-table
_FILE_NAME._PARTITIONTIMEis a hidden/system-defined pseudo column (is_hidden = YES,is_system_defined = YES,is_partitioning_column = YES) withordinal_position IS NULL. That's the case #21220 already handles: schema sync now excludes hidden columns (WHERE is_hidden = 'NO') and skips any remaining NULL ordinals, so these two pseudo columns no longer abort the whole database sync.