Skip to content
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

[protocol] Add a ColumnSchema abstraction? #253

Open
pitrou opened this issue Sep 5, 2023 · 0 comments
Open

[protocol] Add a ColumnSchema abstraction? #253

pitrou opened this issue Sep 5, 2023 · 0 comments

Comments

@pitrou
Copy link

pitrou commented Sep 5, 2023

Instead of having individual methods to query the DType, categorical description, null description and metadata (which I suspect might be replicated at the DataFrame level?), how about adding a first-class abstraction to tie them together? For example:

class ColumnSchema(TypedDict):
    # the underlying physical representation
    dtype: DType
    # if the column is categorical, describes how to interpret the contents
    categorical_encoding: Optional[CategoricalDescription]
    # if the column supports null values, describes how they are represented
    null_encoding: Optional[Tuple[ColumnNullType, Any]]
    # arbitrary metadata attached to the column, possibly empty
    metadata: Dict[str, Any]

class Column(ABC):
    ...
    @property
    @abstractmethod
    def schema(self) -> ColumnSchema: ...

(IMHO, "encoding" sounds more precise than "description")

I'm also not sure why the spec uses a mix of Tuples and TypedDicts. Is it an attempt at optimizing Python object footprint?

@pitrou pitrou changed the title Add a ColumnSchema abstraction? [protocol] Add a ColumnSchema abstraction? Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants