SNOW-2359402 Enabled autoswitching on some unsupported args#3906
SNOW-2359402 Enabled autoswitching on some unsupported args#3906sfc-gh-jenzhang merged 25 commits intomainfrom
Conversation
…into not-implemented-args
…into not-implemented-args
…into not-implemented-args
…/snowpark-python into not-implemented-args
src/snowflake/snowpark/modin/plugin/compiler/snowflake_query_compiler.py
Outdated
Show resolved
Hide resolved
…ompiler.py Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
src/snowflake/snowpark/modin/plugin/compiler/snowflake_query_compiler.py
Show resolved
Hide resolved
src/snowflake/snowpark/modin/plugin/compiler/snowflake_query_compiler.py
Outdated
Show resolved
Hide resolved
src/snowflake/snowpark/modin/plugin/compiler/snowflake_query_compiler.py
Show resolved
Hide resolved
src/snowflake/snowpark/modin/plugin/compiler/snowflake_query_compiler.py
Outdated
Show resolved
Hide resolved
src/snowflake/snowpark/modin/plugin/compiler/snowflake_query_compiler.py
Outdated
Show resolved
Hide resolved
src/snowflake/snowpark/modin/plugin/compiler/snowflake_query_compiler.py
Outdated
Show resolved
Hide resolved
src/snowflake/snowpark/modin/plugin/extensions/base_overrides.py
Outdated
Show resolved
Hide resolved
src/snowflake/snowpark/modin/plugin/compiler/snowflake_query_compiler.py
Outdated
Show resolved
Hide resolved
sfc-gh-joshi
left a comment
There was a problem hiding this comment.
Discussed with @sfc-gh-jenzhang offline about the added axis=1 argument to sort_columns_by_row_values, even though it's technically redundant because the QC method always operates on axis=1. This is necessary because when stay_cost is computed, the decorator compares against the frontend method's arguments to return COST_IMPOSSIBLE, but when the wrapped QC method is called, the decorated examines the arguments of the QC method instead.
Alternative options to enable switching for this case were:
- Don't add a QC argument, and use
lambda args: args.get("axis", 1) == 1for the condition instead of just("axis", 1)-- works but is harder to understand - Keep unsupported condition as
("axis", 1)but don't addaxis=1argument: will trigger an auto-switch, but when switching is disabled will not trigger the decorator's error message code path because the QC method lacks anaxisparameter - Set unsupported condition to be unconditional (e.g.
lambda args: True): will trigger auto-switch even for supported use cases
We decided just adding a docstring comment explaining the addition of the parameter would be better.
…ompiler.py Co-authored-by: Jonathan Shi <149419494+sfc-gh-joshi@users.noreply.github.com>
src/snowflake/snowpark/modin/plugin/compiler/snowflake_query_compiler.py
Show resolved
Hide resolved
src/snowflake/snowpark/modin/plugin/compiler/snowflake_query_compiler.py
Outdated
Show resolved
Hide resolved
sfc-gh-nkrishna
left a comment
There was a problem hiding this comment.
Left one question, but approving to unblock
| if axis in (1, "index"): | ||
| if axis == 1: |
There was a problem hiding this comment.
This is redundant because the frontend layer already parses "index" to 1.
…/snowpark-python into not-implemented-args
| lambda args: ( | ||
| args.get("index") is not None | ||
| and ( | ||
| not isinstance(args.get("index"), str) | ||
| and not all([isinstance(v, str) for v in args.get("index")]) | ||
| and None not in args.get("index") | ||
| ) | ||
| ), |
There was a problem hiding this comment.
The condition logic has a potential issue when handling non-string, non-iterable values for index. If index is a scalar value like an integer, the expression all([isinstance(v, str) for v in args.get("index")]) will attempt to iterate over a non-iterable object, causing a TypeError.
Consider restructuring this condition to first check if the value is iterable before attempting to iterate over it, or use a try/except block to handle this case. A safer approach might be:
lambda args: (
args.get("index") is not None
and not isinstance(args.get("index"), str)
and (
not hasattr(args.get("index"), "__iter__")
or not all(isinstance(v, str) for v in args.get("index"))
)
and None not in (args.get("index") if hasattr(args.get("index"), "__iter__") else [args.get("index")])
)The same issue appears in the similar conditions for columns and values parameters.
| lambda args: ( | |
| args.get("index") is not None | |
| and ( | |
| not isinstance(args.get("index"), str) | |
| and not all([isinstance(v, str) for v in args.get("index")]) | |
| and None not in args.get("index") | |
| ) | |
| ), | |
| lambda args: ( | |
| args.get("index") is not None | |
| and not isinstance(args.get("index"), str) | |
| and ( | |
| not hasattr(args.get("index"), "__iter__") | |
| or not all(isinstance(v, str) for v in args.get("index")) | |
| ) | |
| and None not in ( | |
| args.get("index") if hasattr(args.get("index"), "__iter__") else [args.get("index")] | |
| ) | |
| ), |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.
Fixes SNOW-2359402
Fill out the following pre-review checklist:
Please describe how your code solves the related issue.