Skip to content

Commit 92cc40a

Browse files
committed
ENH: add a check for unsupported by pandas data types for query results
1 parent 73b2c28 commit 92cc40a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

scripts/python/idc_index_data_manager.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,18 @@ def save_schema_to_json(
271271
sql_query: The SQL query string to parse for column descriptions
272272
output_dir: Optional directory path for the output file
273273
"""
274+
# Check for unsupported types that pandas cannot handle properly
275+
unsupported_types = {"DATE", "TIME", "DATETIME", "GEOGRAPHY", "JSON"}
276+
for field in schema:
277+
if field.field_type in unsupported_types:
278+
error_msg = (
279+
f"Unsupported type '{field.field_type}' found for column '{field.name}' "
280+
f"in {output_basename}. Pandas does not properly support this BigQuery type. "
281+
f"Please convert this column to a supported type (e.g., STRING or TIMESTAMP)."
282+
)
283+
logger.error(error_msg)
284+
raise ValueError(error_msg)
285+
274286
# Parse column descriptions from SQL comments
275287
logger.debug("Parsing column descriptions from SQL query comments")
276288
logger.debug(sql_query)

0 commit comments

Comments
 (0)