|
| 1 | +# Copyright 2026 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +import bigframes.bigquery as bbq |
| 16 | + |
| 17 | + |
| 18 | +def test_create_external_table(session, dataset_id, bq_connection): |
| 19 | + table_name = f"{dataset_id}.test_object_table" |
| 20 | + uri = "gs://cloud-samples-data/bigquery/tutorials/cymbal-pets/images/*" |
| 21 | + |
| 22 | + # Create the external table |
| 23 | + table = bbq.create_external_table( |
| 24 | + table_name, |
| 25 | + connection_name=bq_connection, |
| 26 | + options={"object_metadata": "SIMPLE", "uris": [uri]}, |
| 27 | + session=session, |
| 28 | + ) |
| 29 | + assert table is not None |
| 30 | + |
| 31 | + # Read the table to verify |
| 32 | + import bigframes.pandas as bpd |
| 33 | + |
| 34 | + bf_df = bpd.read_gbq(table_name) |
| 35 | + pd_df = bf_df.to_pandas() |
| 36 | + assert len(pd_df) > 0 |
0 commit comments