Skip to content

Conversation

WillAyd
Copy link
Contributor

@WillAyd WillAyd commented Sep 6, 2024

This should fix the issue described in https://github.com/duckdb/duckdb/pull/13418/files#r1746662887

@WillAyd WillAyd force-pushed the add-requested-schema branch from 66e66cd to 6c4972d Compare September 6, 2024 16:14
@duckdb-draftbot duckdb-draftbot marked this pull request as draft September 6, 2024 16:14
@WillAyd WillAyd marked this pull request as ready for review September 6, 2024 16:19
@WillAyd WillAyd force-pushed the add-requested-schema branch from 6c4972d to e9dcac8 Compare September 6, 2024 16:20
@duckdb-draftbot duckdb-draftbot marked this pull request as draft September 6, 2024 16:20
@WillAyd WillAyd marked this pull request as ready for review September 6, 2024 16:22
@WillAyd WillAyd force-pushed the add-requested-schema branch from e9dcac8 to 62ff2db Compare September 6, 2024 17:11
@duckdb-draftbot duckdb-draftbot marked this pull request as draft September 6, 2024 17:11
@WillAyd WillAyd marked this pull request as ready for review September 6, 2024 17:23
@WillAyd WillAyd force-pushed the add-requested-schema branch from 62ff2db to 38489c4 Compare September 6, 2024 17:56
@duckdb-draftbot duckdb-draftbot marked this pull request as draft September 6, 2024 17:57
@WillAyd WillAyd marked this pull request as ready for review September 6, 2024 18:06
@@ -412,7 +412,7 @@ class DuckDBPyRelation:
def list(self, column: str, groups: str = ..., window_spec: str = ..., projected_columns: str = ...) -> DuckDBPyRelation: ...

def arrow(self, batch_size: int = ...) -> pyarrow.lib.Table: ...
def __arrow_c_stream__(self) -> object: ...
def __arrow_c_stream__(self, requested_schema: Any) -> object: ...
Copy link

@kylebarron kylebarron Sep 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this will produce any issues, but the spec document suggests typing this as object | None = None https://arrow.apache.org/docs/format/CDataInterface/PyCapsuleInterface.html#protocol-typehints

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this will mess with type checkers as long as you don't have =None

Pylance doesn't allow this:

from typing import Protocol, Any


class ArrowStreamExportable(Protocol):
    def __arrow_c_stream__(self, requested_schema: object | None = None) -> object: ...


def accepts_arrow(data: ArrowStreamExportable): ...


class ArrowObject:
    def __arrow_c_stream__(self, requested_schema: Any) -> object: ...

obj = ArrowObject()
accepts_arrow(obj)

with error:

Argument of type "ArrowObject" cannot be assigned to parameter "data" of type "ArrowStreamExportable" in function "accepts_arrow"
  "ArrowObject" is incompatible with protocol "ArrowStreamExportable"
    "__arrow_c_stream__" is an incompatible type
      Type "(requested_schema: Any) -> object" is not assignable to type "(requested_schema: object | None = None) -> object"
        Parameter "requested_schema" is missing default argument

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch - thanks!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@WillAyd WillAyd force-pushed the add-requested-schema branch from 38489c4 to 57a53d1 Compare September 6, 2024 18:46
@duckdb-draftbot duckdb-draftbot marked this pull request as draft September 6, 2024 18:47
@WillAyd WillAyd marked this pull request as ready for review September 6, 2024 18:47
@@ -412,7 +412,7 @@ class DuckDBPyRelation:
def list(self, column: str, groups: str = ..., window_spec: str = ..., projected_columns: str = ...) -> DuckDBPyRelation: ...

def arrow(self, batch_size: int = ...) -> pyarrow.lib.Table: ...
def __arrow_c_stream__(self) -> object: ...
def __arrow_c_stream__(self, requested_schema: Optional[object]) -> object: ...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You still need to provide = None, see #13802 (comment)

@WillAyd WillAyd force-pushed the add-requested-schema branch from 57a53d1 to 8c4e21e Compare September 6, 2024 18:49
@duckdb-draftbot duckdb-draftbot marked this pull request as draft September 6, 2024 18:50
@WillAyd WillAyd marked this pull request as ready for review September 6, 2024 18:50
Copy link
Contributor

@Tishj Tishj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@Mytherin Mytherin merged commit a6f4367 into duckdb:main Sep 10, 2024
17 checks passed
@WillAyd WillAyd deleted the add-requested-schema branch September 11, 2024 02:01
github-actions bot pushed a commit to duckdb/duckdb-r that referenced this pull request Sep 25, 2024
Merge pull request duckdb/duckdb#13745 from pdet/decimal_cast
Merge pull request duckdb/duckdb#13802 from WillAyd/add-requested-schema
github-actions bot added a commit to duckdb/duckdb-r that referenced this pull request Sep 25, 2024
Merge pull request duckdb/duckdb#13745 from pdet/decimal_cast
Merge pull request duckdb/duckdb#13802 from WillAyd/add-requested-schema

Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants