@@ -1045,29 +1045,30 @@ def read_gbq_query(
10451045 # local node. Likely there are a wide range of sizes in which it
10461046 # makes sense to download the results beyond the first page, even if
10471047 # there is a job and destination table available.
1048- if (
1049- rows is not None
1050- and destination is None
1051- and (
1052- query_job_for_metrics is None
1053- or query_job_for_metrics .statement_type == "SELECT"
1054- )
1055- ):
1048+ if query_job_for_metrics is None and rows is not None :
10561049 return bf_read_gbq_query .create_dataframe_from_row_iterator (
10571050 rows ,
10581051 session = self ._session ,
10591052 index_col = index_col ,
10601053 columns = columns ,
10611054 )
10621055
1056+ # We already checked rows, so if there's no destination table, then
1057+ # there are no results to return.
1058+ if destination is None :
1059+ return bf_read_gbq_query .create_dataframe_from_query_job_stats (
1060+ query_job_for_metrics ,
1061+ session = self ._session ,
1062+ )
1063+
10631064 # If the query was DDL or DML, return some job metadata. See
10641065 # https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobStatistics2.FIELDS.statement_type
10651066 # for possible statement types. Note that destination table does exist
10661067 # for some DDL operations such as CREATE VIEW, but we don't want to
10671068 # read from that. See internal issue b/444282709.
1068- if destination is None or (
1069+ if (
10691070 query_job_for_metrics is not None
1070- and query_job_for_metrics . statement_type != "SELECT"
1071+ and not bf_read_gbq_query . should_return_query_results ( query_job_for_metrics )
10711072 ):
10721073 return bf_read_gbq_query .create_dataframe_from_query_job_stats (
10731074 query_job_for_metrics ,
0 commit comments