4 ms·
This is the example at https://github.com/looker-open-source/malloy https://github.com/looker-open-source/malloy query: table('malloy-data.faa.flights') -> {
by cryptonector 4y ago
This is the example at https://github.com/looker-open-source/malloy https://github.com/looker-open-source/malloy
query: table('malloy-data.faa.flights') -> {
where: origin ? 'SFO'
group_by: carrier
aggregate:
flight_count is count()
average_flight_time is flight_time.avg()
}
SELECT
carrier,
COUNT(*) as flight_count,
AVG(flight_time) as average_flight_time
FROM `malloy-data.faa.flights`
WHERE origin = 'SFO'
GROUP BY carrier
ORDER BY flight_count desc -- malloy automatically orders by the first aggregate
I don't see much value in this. This is not aesthetically better than SQL. It's also semantically better. This is just a different syntax that would parse to the same AST. And what's with the `?` for equality?!
- ape4 4y agoYeah the ? for equals is not better
- cryptonector 4y agoNone of it is. Examples of things that would be better would be syntax for reference dereferencing. E.g., in SQL-like syntax: SELECT user->home_server->OS_version.version AS v, user->home_server->OS_version.is_obsolete AS obsolete FROM users WHERE name = 'whatever'; or SELECT user->home_server->OS_version.{version, is_obsolete} AS {version, obsolete} FROM users WHERE name = 'whatever'; where we don't have to join to the home servers table or the OS versions table, and also we don't have to repeat ourselves too much. Where the relations are not 1-1 then an array_agg() aggregation could be inferred, or some alternative aggregation could be explicitly given: -- this would be an array of {name, type} values SELECT g.members.{name, type} FROM groups g WHERE g.name = 'whatever'; -- ditto SELECT g.members.{name, type}.array_agg() FROM groups g WHERE g.name = 'whatever'; SELECT g.members.name.count() FROM groups g WHERE g.name = 'whatever'; Now all that would be fantastic. Tinkering with totally different syntax where the shape of the query looks just about the same as in SQL seems like a dead end to me.
- wruza 4y agohttps://1c-dn.com/library/query_language/ https://1c-dn.com/library/query_language/ It was a pleasure to work with business logic on this platform, but sadly it went completely nuts trying to implement “async” web compatibility in a traditionally procedural language in recent versions. Also it is russian-oriented (and I guess you can safely replace “oriented” with “only” for the next decade at least). SQL definitely has a huge growth potential as a language, but you can’t tell internet about it without being instantly dismissed.
- ThunderSizzle 4y agoAnd this basically gets us to EF Navigation Propeties with LINQ. users .Where( user => user.name == "whatever") .Select( user => new { v = user.home_server.OS_version .version, obsolete = user.home_server.OS_version.obsolete })
- ltabb 4y agoTry writing this SQL. Malloy writes SQL you can't (I'm pretty sure of it). https://twitter.com/lloydtabb/status/1556287859601985536
- IIAOPSW 4y agoSQL + recursive queries (an extension supported by everyone since the late 90s) is Turing complete. Thus every arrangement and selection of data is reachable by a query. Therefore there is nothing Malloy can do that SQL can't (I'm absolutely sure of it).
- deleted 4y ago[deleted]
- lolinder 4y agoI think OP meant "can't" as in "probably wouldn't be able to come up with the queries", not that it's literally impossible. Malloy compiles to SQL, so it's by definition impossible for it to express something SQL cannot.
- IIAOPSW 4y agoBy that definition, in that case, OP "can't" express themselves in plain English.
- anon84873628 4y agoPretty sure OP meant emphasis on _you_ can't. As in, things a human can't do.
- wruza 4y agoThere is also nothing Java can do that Brainfuck cannot. It is very easy to implement an extensible web server in BF, you just need to F your B.
- 4y ago
- anon84873628 4y agoIt's not about any single query. It's about the reusability of modularized definitions for BI analysis.
- cryptonector 4y agoSQL does reusability using VIEWs and functions.
- carlineng 4y agoAesthetics are largely subjective. Even though I like Malloy syntax better than SQL syntax, the majority of the actual post is dedicated to reasons above and beyond syntax that I think Malloy has promise; specifically, its integration of a semantic layer into the core of the language.
- ehsankia 4y agoTangential, but I never understood why SQL puts the FROM after the SELECT. It's extra confusing because sometimes people want to use aliased fields from the SELECT section in the FROM section but that won't work because its not evaluated in that order. It also makes much more sense to first name the table, then its fields.
- cryptonector 4y agoThere's no real reason. I suspect it would be a very small change to some SQL implementations to allow the various clauses of queries to come in any order.
- sagarm 4y agoThe sparksql dialect does allow the from clause to come first, actually.