-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNOW-966003: Fix Arrow return value for zero-row queries #1832
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the overloading this is good to go by me.
🚢 🚢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢 🚢
The type signature came from me writing this in vscode with the pyright type checker. Looks like mypy and pyright have slightly different behaviour. pyright allows my usage, while mypy does not. Here is a version that satisfies both . I believe the return type of from typing import Literal, overload, reveal_type, NewType
Table = NewType("Table", object)
class Foo:
@overload
def fetch_arrow_all(self, force_return_table: Literal[False]) -> None:
...
@overload
def fetch_arrow_all(self, force_return_table: Literal[True]) -> Table:
...
def fetch_arrow_all(self, force_return_table: bool = False) -> Table | None:
return Table(1) if force_return_table else None
fetch_true = Foo().fetch_arrow_all(True)
fetch_false = Foo().fetch_arrow_all(False)
reveal_type(fetch_true) # Table
reveal_type(fetch_false) # None |
thanks @sfc-gh-mkeller @thomasaarholt , I have applied the change. |
Apologies, I was blinded by what the correct return type. You're absolutely right. |
no worries @thomasaarholt , you are all good! |
Please answer these questions before submitting your pull requests. Thanks!
What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.
Fixes SNOW-966003, dup PR: SNOW-966003: Fix Arrow return value for zero-row queries #1801 (comment)
Fill out the following pre-review checklist:
Please describe how your code solves the related issue.
Please write a short description of how your code change solves the related issue.