@@ -343,15 +343,15 @@ def _collect_schema_from_table(self):
343343 schema_dict = {k : str (v ) for k , v in schema_dict .items ()}
344344 self .columns = list (schema_dict .items ())
345345
346- elif table_type == "pyspark" :
346+ elif table_type == "pyspark" : # pragma: no cover
347347 # Convert PySpark DataFrame to Narwhals to get schema
348- nw_df = nw .from_native (self .tbl )
349- if _is_lazy_frame (data = nw_df ):
350- schema_dict = dict (nw_df .collect_schema ())
351- else :
352- schema_dict = dict (nw_df .schema .items ())
353- schema_dict = {k : str (v ) for k , v in schema_dict .items ()}
354- self .columns = list (schema_dict .items ())
348+ nw_df = nw .from_native (self .tbl ) # pragma: no cover
349+ if _is_lazy_frame (data = nw_df ): # pragma: no cover
350+ schema_dict = dict (nw_df .collect_schema ()) # pragma: no cover
351+ else : # pragma: no cover
352+ schema_dict = dict (nw_df .schema .items ()) # pragma: no cover
353+ schema_dict = {k : str (v ) for k , v in schema_dict .items ()} # pragma: no cover
354+ self .columns = list (schema_dict .items ()) # pragma: no cover
355355
356356 elif table_type in IBIS_BACKENDS :
357357 schema_dict = dict (self .tbl .schema ().items ())
@@ -888,80 +888,6 @@ def _schema_info_generate_params_dict(
888888 }
889889
890890
891- def _check_schema_match (
892- data_tbl : any ,
893- schema : Schema ,
894- complete : bool = True ,
895- in_order : bool = True ,
896- case_sensitive_colnames : bool = True ,
897- case_sensitive_dtypes : bool = True ,
898- full_match_dtypes : bool = True ,
899- ) -> bool :
900- """
901- Check if the schema matches the target table.
902-
903- This function performs schema validation and returns a boolean result.
904-
905- Parameters
906- ----------
907- data_tbl
908- The target table to validate.
909- schema
910- The expected schema.
911- complete
912- Whether the schema should be complete.
913- in_order
914- Whether the schema should be in order.
915- case_sensitive_colnames
916- Whether column names are case-sensitive.
917- case_sensitive_dtypes
918- Whether data types are case-sensitive.
919- full_match_dtypes
920- Whether data types must match exactly.
921-
922- Returns
923- -------
924- bool
925- True if the schema matches, False otherwise.
926- """
927- validation_info = _get_schema_validation_info (
928- data_tbl = data_tbl ,
929- schema = schema ,
930- passed = False , # This will be determined by the logic below
931- complete = complete ,
932- in_order = in_order ,
933- case_sensitive_colnames = case_sensitive_colnames ,
934- case_sensitive_dtypes = case_sensitive_dtypes ,
935- full_match_dtypes = full_match_dtypes ,
936- )
937-
938- # Determine if the schema validation passed based on the validation info
939- passed = True
940-
941- # Check completeness requirement
942- if complete and not validation_info ["columns_full_set" ]:
943- passed = False
944-
945- # Check order requirement
946- if in_order and not validation_info ["columns_matched_in_order" ]:
947- passed = False
948-
949- # Check if all expected columns were found
950- if validation_info ["columns_not_found" ]:
951- passed = False
952-
953- # Check column-specific validations
954- for col_info in validation_info ["columns" ].values ():
955- if not col_info ["colname_matched" ]:
956- passed = False
957- if not col_info .get (
958- "dtype_matched" , True
959- ): # dtype_matched may not exist if no dtypes specified
960- passed = False
961-
962- return passed
963-
964-
965891def _get_schema_validation_info (
966892 data_tbl : any ,
967893 schema : Schema ,
0 commit comments