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

Precedence for @ is too low when used with + #12518

Closed
2 tasks done
norcalli opened this issue Jun 13, 2024 · 2 comments
Closed
2 tasks done

Precedence for @ is too low when used with + #12518

norcalli opened this issue Jun 13, 2024 · 2 comments
Labels
expected behavior The behavior described in the issue is expected

Comments

@norcalli
Copy link

What happens?

D select @x + 5 from (select -1 as x);
┌────────────┐
│ @((x + 5)) │
│   int32    │
├────────────┤
│          4 │
└────────────┘

As the column header shows, it is parsing as @(x + 5) not (@x) + 5, which seems very surprising to me.

To Reproduce

D select @x + 5 from (select -1 as x);
┌────────────┐
│ @((x + 5)) │
│   int32    │
├────────────┤
│          4 │
└────────────┘

OS:

x64 linux

DuckDB Version:

1.0.0

DuckDB Client:

CLI

Full Name:

Ashkan Kiani

Affiliation:

Jane Street

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
@szarnyasg
Copy link
Collaborator

Hi @norcalli, thanks for opening this issue. PostgreSQL also returns 4 for the same query.

postgres=# select @x + 5 from (select -1 as x) s;
 ?column?
----------
        4
(1 row)

In general, we strive to be compatible with PostgreSQL, so this is expected behaviour.

@szarnyasg szarnyasg added expected behavior The behavior described in the issue is expected and removed needs triage labels Jun 13, 2024
@norcalli
Copy link
Author

Thank you for the quick response, I didn't realize this was also an operator in postgres.
I did find it pretty surprising, so I'll stick to using abs() instead.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expected behavior The behavior described in the issue is expected
Projects
None yet
Development

No branches or pull requests

2 participants