Skip to content

Commit eb5cb76

Browse files
avoid read api where result small
1 parent 9c04587 commit eb5cb76

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

bigframes/core/nodes.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,6 @@ def remap_refs(
743743
return self
744744

745745

746-
## Put ordering in here or just add order_by node above?
747746
@dataclasses.dataclass(frozen=True, eq=False)
748747
class ReadTableNode(LeafNode):
749748
source: bq_data.BigqueryDataSource
@@ -753,11 +752,6 @@ class ReadTableNode(LeafNode):
753752

754753
table_session: bigframes.session.Session = dataclasses.field()
755754

756-
# DELETE BEFORE SUBMITTING, DEBUG ONLY
757-
def __post_init__(self):
758-
for item in self.scan_list.items:
759-
assert item.source_id in self.source.schema.names
760-
761755
def _validate(self):
762756
# enforce invariants
763757
physical_names = set(map(lambda i: i.name, self.source.table.physical_schema))

bigframes/session/bq_caching_executor.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -623,18 +623,14 @@ def _execute_plan_gbq(
623623

624624
create_table = True
625625
if not cache_spec.cluster_cols:
626+
assert len(cache_spec.cluster_cols) <= _MAX_CLUSTER_COLUMNS
626627
offsets_id = bigframes.core.identifiers.ColumnId(
627628
bigframes.core.guid.generate_guid()
628629
)
629630
plan = nodes.PromoteOffsetsNode(plan, offsets_id)
630631
cluster_cols = [offsets_id.sql]
631632
else:
632-
cluster_cols = [
633-
col
634-
for col in cache_spec.cluster_cols
635-
if bigframes.dtypes.is_clusterable(plan.schema.get_type(col))
636-
]
637-
cluster_cols = cluster_cols[:_MAX_CLUSTER_COLUMNS]
633+
cluster_cols = cache_spec.cluster_cols
638634

639635
compiled = compile.compile_sql(
640636
compile.CompileRequest(
@@ -690,7 +686,11 @@ def _execute_plan_gbq(
690686
execution_metadata = executor.ExecutionMetadata.from_iterator_and_job(
691687
iterator, query_job
692688
)
693-
if result_bq_data is not None:
689+
result_mostly_cached = (
690+
hasattr(iterator, "_is_almost_completely_cached")
691+
and iterator._is_almost_completely_cached()
692+
)
693+
if result_bq_data is not None and not result_mostly_cached:
694694
return executor.BQTableExecuteResult(
695695
data=result_bq_data,
696696
project_id=self.bqclient.project,

0 commit comments

Comments
 (0)