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

Documentation for "..." in projection #22

Open
manor opened this issue Apr 5, 2021 · 1 comment
Open

Documentation for "..." in projection #22

manor opened this issue Apr 5, 2021 · 1 comment
Labels
question Further information is requested

Comments

@manor
Copy link
Contributor

manor commented Apr 5, 2021

I get why this:

join(c: Country.name, n:["Palau", "Nauru"].item) {...c}

returns this:

image

and even why this:

join(c: Country.name, n:["Palau", "Nauru"].item) {...n}

returns this:

image

but what does this even mean?

join(c: Country.name, n:["Palau", "Nauru"].item) {...}

because this is what it returns:

image

In the context of a project, '...' means all the columns, but the type of the result of the join and/or the meaning of "..." are a bit unclear. Also, I understand rows and tables but it looks like entire structs are being returned in the last case:

image

@erezsh
Copy link
Owner

erezsh commented Apr 5, 2021

Yes, the join() operation returns a struct for each table. Joining two tables creates two structs.

From the docs (https://preql.readthedocs.io/en/latest/preql-modules.html#join):

Returns: A new table, where each column is a struct representing one of the joined tables.

When you do join_result{...n}, you are telling Preql to inline the struct called n. You could also do join_result{n.item}, with a similar result in that case.

In Preql, my_table {...} is essentially a no-op, which just returns all the columns. If they are structs, they will remain structs.

I hope it's clearer now.

If you have suggestions on how to improve the docs or tutorial, I'll be happy to hear them.

edit: You can also do join_result{...n, ...c}, which will inline both structs.

@erezsh erezsh added the question Further information is requested label Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants