@@ -232,20 +232,28 @@ def read_gbq(
232232 query_or_table : str ,
233233 * ,
234234 index_col : Iterable [str ] | str = (),
235- col_order : Iterable [str ] = (),
235+ columns : Iterable [str ] = (),
236236 max_results : Optional [int ] = None ,
237237 filters : third_party_pandas_gbq .FiltersType = (),
238238 use_cache : bool = True ,
239+ col_order : Iterable [str ] = (),
239240 # Add a verify index argument that fails if the index is not unique.
240241 ) -> dataframe .DataFrame :
241242 # TODO(b/281571214): Generate prompt to show the progress of read_gbq.
242- query_or_table = self ._filters_to_query (query_or_table , col_order , filters )
243+ if columns and col_order :
244+ raise ValueError (
245+ "Must specify either columns (preferred) or col_order, not both"
246+ )
247+ elif col_order :
248+ columns = col_order
249+
250+ query_or_table = self ._filters_to_query (query_or_table , columns , filters )
243251
244252 if _is_query (query_or_table ):
245253 return self ._read_gbq_query (
246254 query_or_table ,
247255 index_col = index_col ,
248- col_order = col_order ,
256+ columns = columns ,
249257 max_results = max_results ,
250258 api_name = "read_gbq" ,
251259 use_cache = use_cache ,
@@ -257,7 +265,7 @@ def read_gbq(
257265 return self ._read_gbq_table (
258266 query_or_table ,
259267 index_col = index_col ,
260- col_order = col_order ,
268+ columns = columns ,
261269 max_results = max_results ,
262270 api_name = "read_gbq" ,
263271 use_cache = use_cache ,
@@ -388,9 +396,10 @@ def read_gbq_query(
388396 query : str ,
389397 * ,
390398 index_col : Iterable [str ] | str = (),
391- col_order : Iterable [str ] = (),
399+ columns : Iterable [str ] = (),
392400 max_results : Optional [int ] = None ,
393401 use_cache : bool = True ,
402+ col_order : Iterable [str ] = (),
394403 ) -> dataframe .DataFrame :
395404 """Turn a SQL query into a DataFrame.
396405
@@ -442,10 +451,17 @@ def read_gbq_query(
442451 """
443452 # NOTE: This method doesn't (yet) exist in pandas or pandas-gbq, so
444453 # these docstrings are inline.
454+ if columns and col_order :
455+ raise ValueError (
456+ "Must specify either columns (preferred) or col_order, not both"
457+ )
458+ elif col_order :
459+ columns = col_order
460+
445461 return self ._read_gbq_query (
446462 query = query ,
447463 index_col = index_col ,
448- col_order = col_order ,
464+ columns = columns ,
449465 max_results = max_results ,
450466 api_name = "read_gbq_query" ,
451467 use_cache = use_cache ,
@@ -456,7 +472,7 @@ def _read_gbq_query(
456472 query : str ,
457473 * ,
458474 index_col : Iterable [str ] | str = (),
459- col_order : Iterable [str ] = (),
475+ columns : Iterable [str ] = (),
460476 max_results : Optional [int ] = None ,
461477 api_name : str = "read_gbq_query" ,
462478 use_cache : bool = True ,
@@ -492,7 +508,7 @@ def _read_gbq_query(
492508 return self .read_gbq_table (
493509 f"{ destination .project } .{ destination .dataset_id } .{ destination .table_id } " ,
494510 index_col = index_cols ,
495- col_order = col_order ,
511+ columns = columns ,
496512 max_results = max_results ,
497513 use_cache = use_cache ,
498514 )
@@ -502,9 +518,10 @@ def read_gbq_table(
502518 query : str ,
503519 * ,
504520 index_col : Iterable [str ] | str = (),
505- col_order : Iterable [str ] = (),
521+ columns : Iterable [str ] = (),
506522 max_results : Optional [int ] = None ,
507523 use_cache : bool = True ,
524+ col_order : Iterable [str ] = (),
508525 ) -> dataframe .DataFrame :
509526 """Turn a BigQuery table into a DataFrame.
510527
@@ -521,10 +538,17 @@ def read_gbq_table(
521538 """
522539 # NOTE: This method doesn't (yet) exist in pandas or pandas-gbq, so
523540 # these docstrings are inline.
541+ if columns and col_order :
542+ raise ValueError (
543+ "Must specify either columns (preferred) or col_order, not both"
544+ )
545+ elif col_order :
546+ columns = col_order
547+
524548 return self ._read_gbq_table (
525549 query = query ,
526550 index_col = index_col ,
527- col_order = col_order ,
551+ columns = columns ,
528552 max_results = max_results ,
529553 api_name = "read_gbq_table" ,
530554 use_cache = use_cache ,
@@ -583,7 +607,7 @@ def _read_gbq_table(
583607 query : str ,
584608 * ,
585609 index_col : Iterable [str ] | str = (),
586- col_order : Iterable [str ] = (),
610+ columns : Iterable [str ] = (),
587611 max_results : Optional [int ] = None ,
588612 api_name : str ,
589613 use_cache : bool = True ,
@@ -602,10 +626,10 @@ def _read_gbq_table(
602626 table_ref , api_name = api_name , use_cache = use_cache
603627 )
604628
605- for key in col_order :
629+ for key in columns :
606630 if key not in table_expression .columns :
607631 raise ValueError (
608- f"Column '{ key } ' of `col_order ` not found in this table."
632+ f"Column '{ key } ' of `columns ` not found in this table."
609633 )
610634
611635 if isinstance (index_col , str ):
@@ -619,8 +643,8 @@ def _read_gbq_table(
619643 f"Column `{ key } ` of `index_col` not found in this table."
620644 )
621645
622- if col_order :
623- table_expression = table_expression .select ([* index_cols , * col_order ])
646+ if columns :
647+ table_expression = table_expression .select ([* index_cols , * columns ])
624648
625649 # If the index is unique and sortable, then we don't need to generate
626650 # an ordering column.
@@ -719,7 +743,7 @@ def _read_bigquery_load_job(
719743 * ,
720744 job_config : bigquery .LoadJobConfig ,
721745 index_col : Iterable [str ] | str = (),
722- col_order : Iterable [str ] = (),
746+ columns : Iterable [str ] = (),
723747 ) -> dataframe .DataFrame :
724748 if isinstance (index_col , str ):
725749 index_cols = [index_col ]
@@ -760,7 +784,7 @@ def _read_bigquery_load_job(
760784 return self .read_gbq_table (
761785 table_id ,
762786 index_col = index_col ,
763- col_order = col_order ,
787+ columns = columns ,
764788 )
765789
766790 def read_gbq_model (self , model_name : str ):
@@ -959,13 +983,13 @@ def read_csv(
959983 if index_col is None :
960984 index_col = ()
961985
962- # usecols should only be an iterable of strings (column names) for use as col_order in read_gbq.
963- col_order : Tuple [Any , ...] = tuple ()
986+ # usecols should only be an iterable of strings (column names) for use as columns in read_gbq.
987+ columns : Tuple [Any , ...] = tuple ()
964988 if usecols is not None :
965989 if isinstance (usecols , Iterable ) and all (
966990 isinstance (col , str ) for col in usecols
967991 ):
968- col_order = tuple (col for col in usecols )
992+ columns = tuple (col for col in usecols )
969993 else :
970994 raise NotImplementedError (
971995 "BigQuery engine only supports an iterable of strings for `usecols`. "
@@ -1000,7 +1024,7 @@ def read_csv(
10001024 table ,
10011025 job_config = job_config ,
10021026 index_col = index_col ,
1003- col_order = col_order ,
1027+ columns = columns ,
10041028 )
10051029 else :
10061030 if any (arg in kwargs for arg in ("chunksize" , "iterator" )):
0 commit comments