Skip to content

Commit ff1bfe7

Browse files
Merge branch 'main' into helmeleegy-SNOW-2338542
2 parents efad3c5 + 20b4d51 commit ff1bfe7

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
#### Improvements
1414

15+
- Hybrid execution mode is now enabled by default. Certain operations on smaller data will now automatically execute in native pandas in-memory. Use `from modin.config import AutoSwitchBackend; AutoSwitchBackend.disable()` to turn this off and force all execution to occur in Snowflake.
1516
- Added a session parameter `pandas_hybrid_execution_enabled` to enable/disable hybrid execution as an alternative to using `AutoSwitchBackend`.
17+
- Removed an unnecessary `SHOW OBJECTS` query issued from `read_snowflake` under certain conditions.
1618

1719
## 1.39.0 (YYYY-MM-DD)
1820

@@ -81,7 +83,6 @@
8183

8284
#### Improvements
8385

84-
- Hybrid execution mode is now enabled by default. Certain operations on smaller data will now automatically execute in native pandas in-memory. Use `from modin.config import AutoSwitchBackend; AutoSwitchBackend.disable()` to turn this off and force all execution to occur in Snowflake.
8586
- Downgraded to level `logging.DEBUG - 1` the log message saying that the
8687
Snowpark `DataFrame` reference of an internal `DataFrameReference` object
8788
has changed.

src/snowflake/snowpark/modin/plugin/_internal/utils.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@ def _create_read_only_table(
322322
def create_initial_ordered_dataframe(
323323
table_name_or_query: Union[str, Iterable[str]],
324324
enforce_ordering: bool,
325+
*,
325326
dummy_row_pos_mode: bool = False,
327+
row_count_hint: Optional[int] = None,
326328
) -> tuple[OrderedDataFrame, str]:
327329
"""
328330
create read only temp table on top of the existing table or Snowflake query if required, and create a OrderedDataFrame
@@ -334,6 +336,11 @@ def create_initial_ordered_dataframe(
334336
enforce_ordering: If True, create a read only temp table on top of the existing table or Snowflake query,
335337
and create the OrderedDataFrame using the read only temp table created.
336338
Otherwise, directly using the existing table.
339+
dummy_row_pos_mode: If True, uses "dummy" row position columns to avoid a potentially
340+
expensive ROW_NUMBER() query.
341+
row_count_hint: An optional hint for the exact row count of the frame. This is used in scenarios
342+
where we have already performed a query for the size of the underlying data, and can re-use
343+
the value.
337344
338345
Returns:
339346
OrderedDataFrame with row position column.
@@ -502,8 +509,10 @@ def create_initial_ordered_dataframe(
502509
ordered_dataframe.row_position_snowflake_quoted_identifier
503510
)
504511

505-
materialized_row_count = None
506-
if not is_query:
512+
if row_count_hint is not None:
513+
ordered_dataframe.row_count = row_count_hint
514+
ordered_dataframe.row_count_upper_bound = row_count_hint
515+
elif not is_query:
507516
materialized_row_count = get_object_metadata_row_count(table_name_or_query)
508517
ordered_dataframe.row_count = materialized_row_count
509518
ordered_dataframe.row_count_upper_bound = materialized_row_count

src/snowflake/snowpark/modin/plugin/compiler/snowflake_query_compiler.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,11 @@ def from_snowflake(
14791479
table_name_or_query=name_or_query,
14801480
enforce_ordering=enforce_ordering,
14811481
dummy_row_pos_mode=dummy_row_pos_mode,
1482+
row_count_hint=(
1483+
relaxed_query_compiler._modin_frame.ordered_dataframe.row_count
1484+
if relaxed_query_compiler is not None
1485+
else None
1486+
),
14821487
)
14831488
pandas_labels_to_snowflake_quoted_identifiers_map = {
14841489
# pandas labels of resulting Snowpark pandas dataframe will be snowflake identifier

0 commit comments

Comments
 (0)