@@ -651,35 +651,36 @@ def _validate_result_schema(
651651 array_value : bigframes .core .ArrayValue ,
652652 bq_schema : list [bigquery .SchemaField ],
653653 ):
654- actual_schema = tuple (bq_schema )
654+ actual_schema = _sanitize ( tuple (bq_schema ) )
655655 ibis_schema = bigframes .core .compile .test_only_ibis_inferred_schema (
656656 self .replace_cached_subtrees (array_value .node )
657- )
658- internal_schema = array_value .schema
657+ ). to_bigquery ()
658+ internal_schema = _sanitize ( array_value .schema . to_bigquery ())
659659 if not bigframes .features .PANDAS_VERSIONS .is_arrow_list_dtype_usable :
660660 return
661661
662- if internal_schema . to_bigquery () != actual_schema :
662+ if internal_schema != actual_schema :
663663 raise ValueError (
664- f"This error should only occur while testing. BigFrames internal schema: { internal_schema . to_bigquery () } does not match actual schema: { actual_schema } "
664+ f"This error should only occur while testing. BigFrames internal schema: { internal_schema } does not match actual schema: { actual_schema } "
665665 )
666- sanitized_schema = _sanitize_for_ibis ( actual_schema )
667- if ibis_schema . to_bigquery () != sanitized_schema :
666+
667+ if ibis_schema != actual_schema :
668668 raise ValueError (
669- f"This error should only occur while testing. Ibis schema: { ibis_schema . to_bigquery () } does not match sanitized schema: { sanitized_schema } "
669+ f"This error should only occur while testing. Ibis schema: { ibis_schema } does not match actual schema: { actual_schema } "
670670 )
671671
672672
673- def _sanitize_for_ibis (
673+ def _sanitize (
674674 schema : Tuple [bigquery .SchemaField , ...]
675675) -> Tuple [bigquery .SchemaField , ...]:
676- # Schema inferred from Ibis does not contain description field. We only need to compare the names, types and modes.
676+ # Schema inferred from SQL strings and Ibis expressions contain only names, types and modes,
677+ # so we disregard other fields (e.g timedelta description for timedelta columns) for validations.
677678 return tuple (
678679 bigquery .SchemaField (
679680 f .name ,
680681 f .field_type ,
681682 f .mode , # type:ignore
682- fields = _sanitize_for_ibis (f .fields ),
683+ fields = _sanitize (f .fields ),
683684 )
684685 for f in schema
685686 )
0 commit comments