@@ -124,7 +124,7 @@ def __init__(
124
124
if len (index_columns ) == 0 :
125
125
warnings .warn (
126
126
"Creating object with Null Index. Null Index is a preview feature." ,
127
- category = bigframes .exceptions .PreviewWarning ,
127
+ category = bigframes .exceptions .NullIndexPreviewWarning ,
128
128
)
129
129
self ._index_columns = tuple (index_columns )
130
130
# Index labels don't need complicated hierarchical access so can store as tuple
@@ -1930,10 +1930,22 @@ def merge(
1930
1930
coalesce_labels = matching_join_labels ,
1931
1931
suffixes = suffixes ,
1932
1932
)
1933
- # Constructs default index
1934
- offset_index_id = guid .generate_guid ()
1935
- expr = joined_expr .promote_offsets (offset_index_id )
1936
- return Block (expr , index_columns = [offset_index_id ], column_labels = labels )
1933
+
1934
+ # Construct a default index only if this object and the other both have
1935
+ # indexes. In other words, joining anything to a NULL index object
1936
+ # keeps everything as a NULL index.
1937
+ #
1938
+ # This keeps us from generating an index if the user joins a large
1939
+ # BigQuery table against small local data, for example.
1940
+ if len (self ._index_columns ) > 0 and len (other ._index_columns ) > 0 :
1941
+ offset_index_id = guid .generate_guid ()
1942
+ expr = joined_expr .promote_offsets (offset_index_id )
1943
+ index_columns = [offset_index_id ]
1944
+ else :
1945
+ expr = joined_expr
1946
+ index_columns = []
1947
+
1948
+ return Block (expr , index_columns = index_columns , column_labels = labels )
1937
1949
1938
1950
def join (
1939
1951
self ,
0 commit comments