@@ -651,35 +651,36 @@ def _validate_result_schema(
651
651
array_value : bigframes .core .ArrayValue ,
652
652
bq_schema : list [bigquery .SchemaField ],
653
653
):
654
- actual_schema = tuple (bq_schema )
654
+ actual_schema = _sanitize ( tuple (bq_schema ) )
655
655
ibis_schema = bigframes .core .compile .test_only_ibis_inferred_schema (
656
656
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 ())
659
659
if not bigframes .features .PANDAS_VERSIONS .is_arrow_list_dtype_usable :
660
660
return
661
661
662
- if internal_schema . to_bigquery () != actual_schema :
662
+ if internal_schema != actual_schema :
663
663
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 } "
665
665
)
666
- sanitized_schema = _sanitize_for_ibis ( actual_schema )
667
- if ibis_schema . to_bigquery () != sanitized_schema :
666
+
667
+ if ibis_schema != actual_schema :
668
668
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 } "
670
670
)
671
671
672
672
673
- def _sanitize_for_ibis (
673
+ def _sanitize (
674
674
schema : Tuple [bigquery .SchemaField , ...]
675
675
) -> 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.
677
678
return tuple (
678
679
bigquery .SchemaField (
679
680
f .name ,
680
681
f .field_type ,
681
682
f .mode , # type:ignore
682
- fields = _sanitize_for_ibis (f .fields ),
683
+ fields = _sanitize (f .fields ),
683
684
)
684
685
for f in schema
685
686
)
0 commit comments