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

feat(api): add .as_scalar() method for turning expressions into scalar subqueries #8350

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

kszucs
Copy link
Member

@kszucs kszucs commented Feb 14, 2024

Since there is no safe way to determine whether a table or a column contains a single cell we need to provide a way for the users to inform ibis that it should treat an expression as a scalar subquery. Previously it was the .to_array() method, but it only worked for table expressions.

Note that when a scalar reduction is passed to certain API methods ibis is able to infer that the value should be turned into a scalar subquery and it implicitly does it. Using this method can be omitted in those cases.

ibis/expr/types/generic.py Show resolved Hide resolved
ibis/expr/types/generic.py Show resolved Hide resolved
ibis/expr/types/core.py Outdated Show resolved Hide resolved
ibis/expr/types/core.py Outdated Show resolved Hide resolved
@kszucs kszucs force-pushed the as_scalar branch 2 times, most recently from a3d6bc7 to 8d6388a Compare February 14, 2024 16:59
@kszucs kszucs enabled auto-merge (squash) February 14, 2024 17:12
@kszucs kszucs merged commit 8130169 into ibis-project:main Feb 14, 2024
72 of 73 checks passed
ncclementi pushed a commit to ncclementi/ibis that referenced this pull request Feb 21, 2024
…lar subqueries (ibis-project#8350)

Since there is no safe way to determine whether a table or a column
contains a single cell we need to provide a way for the users to inform
ibis that it should treat an expression as a scalar subquery. Previously
it was the `.to_array()` method, but it only worked for table
expressions.

Note that when a scalar reduction is passed to certain API methods ibis
is able to infer that the value should be turned into a scalar subquery
and it implicitly does it. Using this method can be omitted in those
cases.
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.

2 participants