Beta Malloy Syntax #29
Replies: 13 comments 14 replies
-
I really like the direction this is taking us—particularly the more prominent labelling of the parts of a query, the explicit bracing of structures, and the riddance of space turtles. Below I've written some ideas/concerns regarding this proposed syntax. In some cases I've provided possible alternatives, but I'm sure I haven't thought of all the relevant use cases, so take the suggestions themselves with a grain of salt. Filter bracketingBracketing filters with Types vs PropertiesIn this proposed syntax, there are two things which are fundamentally different but look very similar. One is definitions with types, e.g. I see two possible concerns with this. 1. Overloading of
|
Beta Was this translation helpful? Give feedback.
-
The One argument would be that Another remedy would be to NOT use
Without the
I can think of reasons for both directions, this could use some discussion. |
Beta Was this translation helpful? Give feedback.
-
I'm much more comfortable with removing the colon to make all these simply "statements" than to add a second separator like |
Beta Was this translation helpful? Give feedback.
-
Interesting. Is there a difference between lists of entities of the same type and collections of entities of multiple types and is it important to reflect those in the language? Current
Square Bracket For All Lists
Curlies for all bracketed expressions
I find "all curlies all the time" unpleasant, but I feel like each one of these has problems. |
Beta Was this translation helpful? Give feedback.
-
This is complex ... |
Beta Was this translation helpful? Give feedback.
-
The query syntax is still fluid. A query is the following things.
The current meta is that the |
Beta Was this translation helpful? Give feedback.
-
True ... we could ...
|
Beta Was this translation helpful? Give feedback.
-
The clam is, given ...
It is clearer in the second form that the The nice thing about @christopherswenson suggestion that we fix this with style ... always surround the arrow with spaces exploreName{ refineMent } -> queryName Still thinking on this |
Beta Was this translation helpful? Give feedback.
-
This one is up in the air a little. Let's say we need to refine a query and the output of the query ...
If I want to refine BOTH
It was a last minute convenience handwave to say "I can tell the parser that in a place where is is expecting an exploreable, you can write |
Beta Was this translation helpful? Give feedback.
-
One other point about the "recognizable right hand sides" comment. It would be really nice if we could have one consolidated grammar for definitions, e.g. I would love it if we could make this a goal/priority for this beta syntax. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Working on converting the tests, I've noticed/wished for: I would love to be able to put multiple statements on the same line. Perhaps semicolon could mean the same thing as new line or something?
|
Beta Was this translation helpful? Give feedback.
-
This was malloy 3.0, I forgot we did this, closing. |
Beta Was this translation helpful? Give feedback.
-
NOTE: This work discussed here is completed and is now the actual syntax.
Alpha Malloy
As of this writing the alpha version of the Malloy syntax is roughly a year old. It has always been our plan that the syntax would be constantly evolving the language, and we may have hit a point where a more significant change in syntax is warranted.
So what would a beta version of the Malloy syntax look like?
The problems ...
The structure free word salad that is alpha-malloy is designed to be as free of punctuation as possible, following a design principle intuited from SQL, to attempt feel familiar to SQL users.
This experiment has produced a lovely small language, but when presented to experience SQL users, there are a few bumps.
One Proposal
In conversation with data-science SQL users, we learn that they mostly know how to read SQL, Python, and JSON. This raises the interesting possibility of going back to a more LookML inspired syntax. The new tao would be something like
Farewell Space Turtles
The thing which queries start from, like in LookML, is called an "explore".
The thing which is a query, is called a "query".
The word "space" which we started throwing around to distinguish between and explore that was a query and and explore which was something which could be queried is now superfluous.
A "turtle", meaning a query declared in an explore, is now is just "a query declared in an explore".
A "turtle", meaning a query nested in a query, is now just a "nested query".
Basic Declaration Form
The basic declaration form on alpha-malloy was evolving into
The beta-malloy LookML-ish syntax would have one of two forms. For a single declaration like the one above it would simply be
as in these statements ...
but will also allow groups of similar types of named objects to be declared with
which will allow grouped blocks of dimensions or joins where that adds readability to a large model
Refinement gesture
Creation of explores in malloy is always a gesture of refinement based on existing object where the simplest object is a table. For example we want
flights
to mean themalloydta.faa.flights
table ...In beta-malloy any time you name a refineable object you can create an enhanced or extended version of the object simply by following the name with the
{}
enclosed set of additional properties.As an example ... this ...
... can be written without having to create an explore for carriers by writing the enhancement inline in the join ...
This is similar to how alpha-malloy works, except this syntax is more regular and less dependant on special case exceptions in the grammar.
Declaration vs. Invocation
Since an "explore" is not a query but a declaration it also contains declarations of dimensions and measures, which in this new syntax must be declared sperately
Farewell
reduce
A query is either a grouping/aggregating gesture, which would look like this ...
... or a detail-gesture like this ...
A
group by
or aproject
have a list of references, or new dimensions. Anaggregate
has a list of measures or new measure definitions. The alpha-malloyreduce
query is a query which starts withgroup by:
and aproject
query starts withproject:
but both are just queries.Farewell
|
The pipe symbols is removed from the language. In an explore definition, there can not be a chain of queries, there is only the declarations of filters, joins, dimensions, measures, and queries.
Filters are
where:
andhaving:
The magic
: []
syntax for filters is gone. An explore or a project query can have awhere:
property, and an aggregating query can have awhere:
and ahaving:
. The value is still a[]
bracketed, comma seperated list of malloy expressions.Query syntax (the
->
)There is an operator,
->
, which as a left hand side takes en explore and for the right hand side takes a query definition ...{ where: ... shorthand }
Because filtering is ubiquitous, there is a shorthand for filtering. We expect authors of models to use
where:
andhaving:
for clarity, but for people writing queries there is a shorthand which is as terse as the alpha-malloy: [ FILTER1, FILTER2 ]
but which feels like a natural shortcut based on existing syntax in beta-malloy ...What about turtles ...
Nested queries are declared in an explore with the
query:
keyword ...And to include a nested query in a result set, much like the
aggregate:
keyword accepts existing names measures, or allows new measures, there is anest:
keyword to nest a query ...Explore from Query
Because an explore can no longer have a
| reduce
in the definition, there needs to be a syntax meaning "the explore which starts with the result of this query". This would be indicated when, anywhere an explore name is legal, to use(
QUERY)
for example.Beta Was this translation helpful? Give feedback.
All reactions