Skip to content

An object should be able to raise an error, if it doesn't have a verb implementation #54

@machow

Description

@machow

Note: if implemented, this change seems impactful enough that an ADR should be written for it

For example, in the example below I create a LazyTbl for mtcars data. However, since semi_join is currently not implemented in SQL, calling semi_join(tbl_mtcars, tbl_mtcars, {"cyl": "cyl"}) results in a Pipeable.

Ideally, an object should be able to declare that by default, if it does not have a method to dispatch for a verb, that it wants to produce an error.

Options

  1. Register globally
  2. Register on each verb
  3. Search for custom method (preferred choice)

For option (3), siu could search for a (class?) method named _siu_dispatch_default, and if it exists, call it.

Impact

Overall, I think this will be a very important behavior. It brings stability to pipes, which provide very clean syntax, but can fail in confusing / unintuitive ways. It uses a similar approach to jupyter notebooks, so hopefully will not be too surprising.

Example

from sqlalchemy import create_engine
from siuba.data import mtcars
import pandas as pd

engine = create_engine('sqlite:///:memory:', echo=False)

# note that mtcars is a pandas DataFrame
mtcars.to_sql('mtcars', engine)

from siuba import semi_join
from siuba.sql import LazyTbl, show_query, collect
tbl_mtcars = LazyTbl(engine, 'mtcars')

semi_join(tbl_mtcars, tbl_mtcars, {"cyl": "cyl"})

Metadata

Metadata

Assignees

No one assigned

    Labels

    .epicHigh level collection of issues, which enable something useful.core:siutype:research

    Projects

    Status

    Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions