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

Positional Reference Operator #1568

Merged
merged 3 commits into from Apr 6, 2021
Merged

Conversation

Mytherin
Copy link
Collaborator

@Mytherin Mytherin commented Apr 2, 2021

This PR introduces the positional reference operator (#) that can be used to refer to specific columns of the FROM clause by position, rather than by name.

For example:

CREATE TABLE integers(i integer, j integer);
INSERT INTO integers VALUES (1, 2), (2, 2), (3, 2);
SELECT #1 FROM integers;
┌───┐
│ i │
├───┤
│ 1 │
│ 2 │
│ 3 │
└───┘

While this can be used from SQL, its primary use-case is for use in the relational API during ad-hoc analysis where column names are generally less accessible, e.g.:

import duckdb
duckdb.values([1, 2]).project('#1 + #2').df()
#   #1 + #2
# 0        3

@Mytherin Mytherin merged commit 957b03c into duckdb:master Apr 6, 2021
@Mytherin Mytherin deleted the hashtagoperator branch July 19, 2021 07:28
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.

None yet

1 participant