Join Extension Syntax #205
mtoy-googly-moogly
started this conversation in
What's Next: Language Proposals
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Where We Are ...
We currently have two join types, which suffice for almost every use of joining in real world data:
Fanning join, uses the primary key of the outer explore to pick many rows in the joined table
Non-fanning join, uses the primary key of the joined explore to pick one row in the joined table
We want to add the following join types (note this is not all the join types in SQL, just the ones useful for Malloy that we don't have)
Here is a discussion log of the proposals ... I am intentionally not using "many-to-one" and "one-to-many" because it is confusing, unclear and unteachable which of two entities is the left side and which is the right side of that phrase.
What we are trying
on
keyword is used only for expression based joinswith
keyword us used to indicate a primary key based joinjoin_one:
orjoin_many:
because the fanning / non-fanning nature of a join is as important is "is this computation a dimension or a measure"Non fanning joins, key or expression based ...
Fanning joins ...
Cross joins
What we considered
Here are some examples of ways we might phrase these new joins in a Malloy-like way
REJECTED (mostly) First Suggestion
join: one stuff on someExpression
join: one container is thing on container.id = id_of_container
join: many stuff on someExpression
join: many contents is thing on id = contents.id_of_container
join: something is somethingElse
join: somethingElse
This is rejected because Malloy wants named things to be written
type: newName is ...definition...
and putting the join type before the name breaks that pattern.The cross-join seems ok though, so we are probably going with "no ON means a cross join"
Type goes left of the colon ...
JOIN underscore
So we first try and push the join type to the left of the colon ...
join_one: stuff on someExpression
join_one: container is thing on container.id = id_of_container
join_many: stuff on someExpression
join_many: contents is thing on id = contents.id_of_container
JOIN space
... or resurrect the idea that the thing left of the colon can be more than one word ...
join one: stuff on someExpression
join one: container is thing on container.id = id_of_container
join many: stuff on someExpression
join many: contents is thing on id = contents.id_of_container
This would then make
primary key:
andgroup by:
... so that's a bigger discussion.Expression joins using {}
Some syntax with joins as bags of properties ... something like:
join: container is { one: thing on: container.id = id_of_container }
join: contents is { many: thing on: id = contents.id_of_container }
Join type after IS
join: container is many thing on container.id = id_of_container
join: contents is one thing on id = contents.id_of_container
Type goes next to preposition
join: stuff one on someExpression
join: container is thing one on container.id = id_of_container
join: stuff many on someExpression
join: contents is thing many on id = contents.id_of_container
Type replaces on
join: stuff one someExpression
join: container is thing one container.id = id_of_container
join: stuff many someExpression
join: contents is thing many id = contents.id_of_container
Preposition implies type
Could pick different words than
using
andhaving
, but something like ...join: stuff using someExpression
join: container is thing using container.id = id_of_container
join: stuff having someExpression
join: contents is stuff having id = contents.id_of_container
[] or other non-word to indicate fanning
join: stuff on someExpression
join: container is thing on container.id = id_of_container
join: stuff[] on someExpression
join: contents is thing[] on id = contents.id_of_container
Beta Was this translation helpful? Give feedback.
All reactions