@@ -5579,6 +5579,41 @@ def test_load_table_from_dataframe_unknown_table(self):
55795579 job_config = mock .ANY ,
55805580 )
55815581
5582+ @unittest .skipIf (pandas is None , "Requires `pandas`" )
5583+ @unittest .skipIf (pyarrow is None , "Requires `pyarrow`" )
5584+ def test_load_table_from_dataframe_no_schema_warning (self ):
5585+ client = self ._make_client ()
5586+
5587+ # Pick at least one column type that translates to Pandas dtype
5588+ # "object". A string column matches that.
5589+ records = [{"name" : "Monty" , "age" : 100 }, {"name" : "Python" , "age" : 60 }]
5590+ dataframe = pandas .DataFrame (records )
5591+
5592+ get_table_patch = mock .patch (
5593+ "google.cloud.bigquery.client.Client.get_table" ,
5594+ autospec = True ,
5595+ side_effect = google .api_core .exceptions .NotFound ("Table not found" ),
5596+ )
5597+ load_patch = mock .patch (
5598+ "google.cloud.bigquery.client.Client.load_table_from_file" , autospec = True
5599+ )
5600+ pyarrow_patch = mock .patch ("google.cloud.bigquery.client.pyarrow" , None )
5601+ catch_warnings = warnings .catch_warnings (record = True )
5602+
5603+ with get_table_patch , load_patch , pyarrow_patch , catch_warnings as warned :
5604+ client .load_table_from_dataframe (
5605+ dataframe , self .TABLE_REF , location = self .LOCATION
5606+ )
5607+
5608+ matches = [
5609+ warning
5610+ for warning in warned
5611+ if warning .category in (DeprecationWarning , PendingDeprecationWarning )
5612+ and "could not be detected" in str (warning )
5613+ and "please provide a schema" in str (warning )
5614+ ]
5615+ assert matches , "A missing schema deprecation warning was not raised."
5616+
55825617 @unittest .skipIf (pandas is None , "Requires `pandas`" )
55835618 @unittest .skipIf (pyarrow is None , "Requires `pyarrow`" )
55845619 def test_load_table_from_dataframe_struct_fields_error (self ):
0 commit comments