3232import math
3333import os
3434import tempfile
35+ import textwrap
3536import uuid
3637import warnings
3738
@@ -354,7 +355,18 @@ def list_datasets(
354355 )
355356
356357 def dataset (self , dataset_id , project = None ):
357- """Construct a reference to a dataset.
358+ """Deprecated: Construct a reference to a dataset.
359+
360+ This method is deprecated. Construct a
361+ :class:`~google.cloud.bigquery.dataset.DatasetReference` using its
362+ constructor or use a string where previously a reference object was
363+ used.
364+
365+ As ``google-cloud-bigquery`` version 1.7.0, all client methods that
366+ take a :class:`~google.cloud.bigquery.dataset.DatasetReference` or
367+ :class:`~google.cloud.bigquery.table.TableReference` also take a
368+ string in standard SQL format, e.g. ``project.dataset_id`` or
369+ ``project.dataset_id.table_id``.
358370
359371 Args:
360372 dataset_id (str): ID of the dataset.
@@ -370,6 +382,15 @@ def dataset(self, dataset_id, project=None):
370382 if project is None :
371383 project = self .project
372384
385+ warnings .warn (
386+ textwrap .fill (
387+ "Client.dataset is deprecated and will be removed in a future version. "
388+ "Use a string like 'my_project.my_dataset' or a "
389+ "cloud.google.bigquery.DatasetReference object, instead."
390+ ),
391+ PendingDeprecationWarning ,
392+ stacklevel = 2 ,
393+ )
373394 return DatasetReference (project , dataset_id )
374395
375396 def _create_bqstorage_client (self ):
@@ -419,7 +440,7 @@ def create_dataset(
419440
420441 >>> from google.cloud import bigquery
421442 >>> client = bigquery.Client()
422- >>> dataset = bigquery.Dataset(client.dataset(' my_dataset') )
443+ >>> dataset = bigquery.Dataset('my_project. my_dataset')
423444 >>> dataset = client.create_dataset(dataset)
424445
425446 """
@@ -2584,7 +2605,7 @@ def list_partitions(self, table, retry=DEFAULT_RETRY, timeout=None):
25842605 ) as guard :
25852606 meta_table = self .get_table (
25862607 TableReference (
2587- self . dataset (table .dataset_id , project = table .project ),
2608+ DatasetReference (table .project , table .dataset_id ),
25882609 "%s$__PARTITIONS_SUMMARY__" % table .table_id ,
25892610 ),
25902611 retry = retry ,
0 commit comments