# Path: pandas_gbq/exceptions.py
# class AccessDenied(ValueError):
#     """
#     Raised when invalid credentials are provided, or tokens have expired.
#     """
# 
# class GenericGBQException(ValueError):
#     """
#     Raised when an unrecognized Google API Error occurs.
#     """
# 
# Path: pandas_gbq/features.py
# FEATURES = Features()


import copy
import concurrent.futures
import logging
import re
import time
import typing
import warnings
import numpy as np
    import pandas
import pandas_gbq.schema
import pandas_gbq.timestamp
    import tqdm  # noqa
        import pkg_resources  # noqa
        import db_dtypes  # noqa
        import pydata_google_auth  # noqa
        import google.auth  # noqa
        import google.api_core.client_info
        import pandas
        import pandas
    import db_dtypes
    import db_dtypes
    import pandas.api.types
from datetime import datetime
from typing import Any, Dict, Optional, Sequence, Union
from pandas_gbq.exceptions import (
    AccessDenied,
    GenericGBQException,
)
from pandas_gbq.features import FEATURES
        from google_auth_oauthlib.flow import InstalledAppFlow  # noqa
        from google.cloud import bigquery  # noqa
        from google.api_core.exceptions import GoogleAPIError
        from google.api_core.exceptions import ClientError
        from pandas_gbq import auth
        from google.cloud import bigquery
        from google.cloud import bigquery
        from google.auth.exceptions import RefreshError
        from google.cloud import bigquery
        from pandas_gbq import load
    from google.api_core import exceptions as google_exceptions
    from google.cloud import bigquery
    from pandas_gbq import schema
        from google.cloud.bigquery import DatasetReference
        from google.cloud.bigquery import TableReference
        from google.api_core.exceptions import NotFound
        from google.cloud.bigquery import DatasetReference
        from google.cloud.bigquery import Table
        from google.cloud.bigquery import TableReference
        from google.api_core.exceptions import NotFound
        from google.cloud.bigquery import DatasetReference
        from google.api_core.exceptions import NotFound
        from google.cloud.bigquery import Dataset
        # Avoid attempting to download results from DML queries, which have no
        # destination.
        if query_reply.destination is None:
            return pandas.DataFrame()

        rows_iter = self.client.list_rows(
            query_reply.destination, max_results=max_results
        )
        return self._download_results(
            rows_iter,
            max_results=max_results,
            progress_bar_type=progress_bar_type,
            user_dtypes=dtypes,
        )

    def _download_results(
        self, rows_iter, max_results=None, progress_bar_type=None, user_dtypes=None,
    ):
        # No results are desired, so don't bother downloading anything.
        if max_results == 0:
            return None

        if user_dtypes is None:
            user_dtypes = {}

        create_bqstorage_client = self.use_bqstorage_api
        if max_results is not None:
            create_bqstorage_client = False

        to_dataframe_kwargs = {}

# Path: pandas_gbq/exceptions.py
# class AccessDenied(ValueError):
#     """
#     Raised when invalid credentials are provided, or tokens have expired.
#     """
# 
# class GenericGBQException(ValueError):
#     """
#     Raised when an unrecognized Google API Error occurs.
#     """
# 
# Path: pandas_gbq/features.py
# FEATURES = Features()


# Path: pandas_gbq/gbq.py
import copy
import concurrent.futures
import logging
import re
import time
import typing
import warnings
import numpy as np
    import pandas
import pandas_gbq.schema
import pandas_gbq.timestamp
    import tqdm  # noqa
        import pkg_resources  # noqa
        import db_dtypes  # noqa
        import pydata_google_auth  # noqa
        import google.auth  # noqa
        import google.api_core.client_info
        import pandas
        import pandas
    import db_dtypes
    import db_dtypes
    import pandas.api.types
from datetime import datetime
from typing import Any, Dict, Optional, Sequence, Union
from pandas_gbq.exceptions import (
    AccessDenied,
    GenericGBQException,
)
from pandas_gbq.features import FEATURES
        from google_auth_oauthlib.flow import InstalledAppFlow  # noqa
        from google.cloud import bigquery  # noqa
        from google.api_core.exceptions import GoogleAPIError
        from google.api_core.exceptions import ClientError
        from pandas_gbq import auth
        from google.cloud import bigquery
        from google.cloud import bigquery
        from google.auth.exceptions import RefreshError
        from google.cloud import bigquery
        from pandas_gbq import load
    from google.api_core import exceptions as google_exceptions
    from google.cloud import bigquery
    from pandas_gbq import schema
        from google.cloud.bigquery import DatasetReference
        from google.cloud.bigquery import TableReference
        from google.api_core.exceptions import NotFound
        from google.cloud.bigquery import DatasetReference
        from google.cloud.bigquery import Table
        from google.cloud.bigquery import TableReference
        from google.api_core.exceptions import NotFound
        from google.cloud.bigquery import DatasetReference
        from google.api_core.exceptions import NotFound
        from google.cloud.bigquery import Dataset

        # Avoid attempting to download results from DML queries, which have no
        # destination.
        if query_reply.destination is None:
            return pandas.DataFrame()

        rows_iter = self.client.list_rows(
            query_reply.destination, max_results=max_results
        )
        return self._download_results(
            rows_iter,
            max_results=max_results,
            progress_bar_type=progress_bar_type,
            user_dtypes=dtypes,
        )

    def _download_results(
        self, rows_iter, max_results=None, progress_bar_type=None, user_dtypes=None,
    ):
        # No results are desired, so don't bother downloading anything.
        if max_results == 0:
            return None

        if user_dtypes is None:
            user_dtypes = {}

        create_bqstorage_client = self.use_bqstorage_api
        if max_results is not None:
            create_bqstorage_client = False

        to_dataframe_kwargs = {}

        if FEATURES.bigquery_needs_date_as_object: