Skip to content

ColumnExpression.__rsub__ produces incorrect (backwards?) output? #16281

@MarcoGorelli

Description

@MarcoGorelli

What happens?

The code below produces

In [6]: print(duckdb.sql('select 1 - a from rel'))
┌─────────┐
│ (1 - a) │
│  int32  │
├─────────┤
│       0 │
│      -2 │
│      -4 │
└─────────┘


In [7]: rel.select(1-duckdb.ColumnExpression('a'))
Out[7]: 
┌─────────┐
│ (a - 1) │
│  int32  │
├─────────┤
│       0 │
│       2 │
│       4 │
└─────────┘

shouldn't they produce the same output?

To Reproduce

import duckdb

rel = duckdb.sql('select * from values (1,2,1), (3,2,2), (5,3,3) df(a, b, i)')
print(duckdb.sql('select 1 - a from rel'))
print(rel.select(1-duckdb.ColumnExpression('a')))

OS:

linux

DuckDB Version:

1.2

DuckDB Client:

python

Hardware:

No response

Full Name:

marco gorelli

Affiliation:

quansight labs

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a stable release

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions