@@ -2098,43 +2098,6 @@ def test_update_table_expiration(client, to_delete):
20982098 # [END bigquery_update_table_expiration]
20992099
21002100
2101- @pytest .mark .skip (
2102- reason = (
2103- "update_table() is flaky "
2104- "https://github.com/GoogleCloudPlatform/google-cloud-python/issues/5589"
2105- )
2106- )
2107- def test_add_empty_column (client , to_delete ):
2108- """Adds an empty column to an existing table."""
2109- dataset_id = "add_empty_column_dataset_{}" .format (_millis ())
2110- table_id = "add_empty_column_table_{}" .format (_millis ())
2111- dataset = bigquery .Dataset (client .dataset (dataset_id ))
2112- dataset = client .create_dataset (dataset )
2113- to_delete .append (dataset )
2114-
2115- table = bigquery .Table (dataset .table (table_id ), schema = SCHEMA )
2116- table = client .create_table (table )
2117-
2118- # [START bigquery_add_empty_column]
2119- # from google.cloud import bigquery
2120- # client = bigquery.Client()
2121- # dataset_id = 'my_dataset'
2122- # table_id = 'my_table'
2123-
2124- table_ref = client .dataset (dataset_id ).table (table_id )
2125- table = client .get_table (table_ref ) # API request
2126-
2127- original_schema = table .schema
2128- new_schema = original_schema [:] # creates a copy of the schema
2129- new_schema .append (bigquery .SchemaField ("phone" , "STRING" ))
2130-
2131- table .schema = new_schema
2132- table = client .update_table (table , ["schema" ]) # API request
2133-
2134- assert len (table .schema ) == len (original_schema ) + 1 == len (new_schema )
2135- # [END bigquery_add_empty_column]
2136-
2137-
21382101@pytest .mark .skip (
21392102 reason = (
21402103 "update_table() is flaky "
@@ -2223,47 +2186,6 @@ def test_update_table_cmek(client, to_delete):
22232186 # [END bigquery_update_table_cmek]
22242187
22252188
2226- def test_browse_table_data (client , to_delete , capsys ):
2227- """Retreive selected row data from a table."""
2228-
2229- # [START bigquery_browse_table]
2230- # from google.cloud import bigquery
2231- # client = bigquery.Client()
2232-
2233- dataset_ref = client .dataset ("samples" , project = "bigquery-public-data" )
2234- table_ref = dataset_ref .table ("shakespeare" )
2235- table = client .get_table (table_ref ) # API call
2236-
2237- # Load all rows from a table
2238- rows = client .list_rows (table )
2239- assert len (list (rows )) == table .num_rows
2240-
2241- # Load the first 10 rows
2242- rows = client .list_rows (table , max_results = 10 )
2243- assert len (list (rows )) == 10
2244-
2245- # Specify selected fields to limit the results to certain columns
2246- fields = table .schema [:2 ] # first two columns
2247- rows = client .list_rows (table , selected_fields = fields , max_results = 10 )
2248- assert len (rows .schema ) == 2
2249- assert len (list (rows )) == 10
2250-
2251- # Use the start index to load an arbitrary portion of the table
2252- rows = client .list_rows (table , start_index = 10 , max_results = 10 )
2253-
2254- # Print row data in tabular format
2255- format_string = "{!s:<16} " * len (rows .schema )
2256- field_names = [field .name for field in rows .schema ]
2257- print (format_string .format (* field_names )) # prints column headers
2258- for row in rows :
2259- print (format_string .format (* row )) # prints row data
2260- # [END bigquery_browse_table]
2261-
2262- out , err = capsys .readouterr ()
2263- out = list (filter (bool , out .split ("\n " ))) # list of non-blank lines
2264- assert len (out ) == 11
2265-
2266-
22672189@pytest .mark .skip (
22682190 reason = (
22692191 "update_table() is flaky "
0 commit comments