@@ -327,18 +327,30 @@ def reset_index(self, drop: bool = True) -> Block:
327
327
A new Block because dropping index columns can break references
328
328
from Index classes that point to this block.
329
329
"""
330
- new_index_col_id = guid .generate_guid ()
331
- expr = self ._expr .promote_offsets (new_index_col_id )
330
+ expr = self ._expr
331
+ if (
332
+ self .session ._default_index_type
333
+ == bigframes .enums .DefaultIndexKind .SEQUENTIAL_INT64
334
+ ):
335
+ new_index_col_id = guid .generate_guid ()
336
+ expr = expr .promote_offsets (new_index_col_id )
337
+ new_index_cols = [new_index_col_id ]
338
+ elif self .session ._default_index_type == bigframes .enums .DefaultIndexKind .NULL :
339
+ new_index_cols = []
340
+ else :
341
+ raise ValueError (
342
+ f"Unrecognized default index kind: { self .session ._default_index_type } "
343
+ )
344
+
332
345
if drop :
333
346
# Even though the index might be part of the ordering, keep that
334
347
# ordering expression as reset_index shouldn't change the row
335
348
# order.
336
349
expr = expr .drop_columns (self .index_columns )
337
350
return Block (
338
351
expr ,
339
- index_columns = [ new_index_col_id ] ,
352
+ index_columns = new_index_cols ,
340
353
column_labels = self .column_labels ,
341
- index_labels = [None ],
342
354
)
343
355
else :
344
356
# Add index names to column index
@@ -362,9 +374,8 @@ def reset_index(self, drop: bool = True) -> Block:
362
374
363
375
return Block (
364
376
expr ,
365
- index_columns = [ new_index_col_id ] ,
377
+ index_columns = new_index_cols ,
366
378
column_labels = column_labels_modified ,
367
- index_labels = [None ],
368
379
)
369
380
370
381
def set_index (
@@ -2096,13 +2107,17 @@ def merge(
2096
2107
#
2097
2108
# This keeps us from generating an index if the user joins a large
2098
2109
# BigQuery table against small local data, for example.
2099
- if len (self ._index_columns ) > 0 and len (other ._index_columns ) > 0 :
2110
+ if (
2111
+ self .index .is_null
2112
+ or other .index .is_null
2113
+ or self .session ._default_index_type == bigframes .enums .DefaultIndexKind .NULL
2114
+ ):
2115
+ expr = joined_expr
2116
+ index_columns = []
2117
+ else :
2100
2118
offset_index_id = guid .generate_guid ()
2101
2119
expr = joined_expr .promote_offsets (offset_index_id )
2102
2120
index_columns = [offset_index_id ]
2103
- else :
2104
- expr = joined_expr
2105
- index_columns = []
2106
2121
2107
2122
return Block (expr , index_columns = index_columns , column_labels = labels )
2108
2123
@@ -2604,6 +2619,10 @@ def column_ids(self) -> Sequence[str]:
2604
2619
"""Column(s) to use as row labels."""
2605
2620
return self ._block ._index_columns
2606
2621
2622
+ @property
2623
+ def is_null (self ) -> bool :
2624
+ return len (self ._block ._index_columns ) == 0
2625
+
2607
2626
def to_pandas (self , * , ordered : Optional [bool ] = None ) -> pd .Index :
2608
2627
"""Executes deferred operations and downloads the results."""
2609
2628
if len (self .column_ids ) == 0 :
0 commit comments