-
Notifications
You must be signed in to change notification settings - Fork 15
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
Feedback from Strange Loop talk #74
Comments
Hi Julian, Thanks for the Strange Loop talk. I've been looking for languages which embrace the relational model and build on SQL. So far in my journey I've discovered:
Even so, I haven't yet found anything better than "WITH RECURSIVE" CTEs and "CREATE VIEW AS" to query data with:
What is your intuition / approach on how Morel will/should handle tree-based and network-based query use cases? David |
I agree that these kinds of queries are important. (I tend to call them 'iterative queries' but others call them 'recursive queries', and 'incremental queries' are closely related.) A functional programming language that treats relations as data values would seem to be a natural approach to such problems. In a development branch (commit f99d4a9) I have added the
Such queries can run via Calcite, being translated to Calcite's RepeatUnion relational operator. I am also experimenting with writing such queries as recursive functions (you can see some examples in that commit). The tricky part is for the language to know that when I call a function recursively and use its return in a union, that has a chance of reaching a fixed point, and therefore the recursion will not go on forever. That would need us to give union some special properties, and I'm not sure what those properties are, or whether they belong to union alone. |
Thanks, I am curious about where this will land. I’m looking for a language that bring expressiveness and simplicity to handling relational data tables that express transitive relations that form trees and directed acyclic graphs. Why aren’t transitive relations first class citizens in the relational model? To your question about termination. I’m curious if there is a generalisation of relational algebra and well behaved operators that would be available if the language enforced acyclic or tree constraints over the input data. One simplistic embodiment of this idea would be a fkey-acyclic constraint, or fkey-tree constraint in self-referential transitive relations expressed as tables. Alternatively, the language could require calling out of the self-referential fkey/primary key and enforce the tree and/or acyclic structure constraint at run time. Do implicit union types play a role here. An early slide in the presentation contains an example of tree algorithms in native ML. I was waiting for this to be folded into Morel. What would it look like if ML, provided the foundations for expressing recursive / iterative queries rather than Calcite? David |
I received the following feedback after my talk at Strange Loop. The feedback is quoted, my answers inline.
Yes, for years I have been doing things like using a 'for' loop to iterate over an array, then binding a parameter and executing a query. Or doing joins, intersections, minus, on collections.
Once these operations are expressed as relational algebra, we can ask ourselves what is the best implementation if the relations are actually collections such as lists, maps (dictionaries), sets.
I have skated over ordering in Morel's language design so far. Lists are ordered and relations are not. If the semantics of a
from
expression imply a particular ordering (and I haven't yet specified whether they do or don't) then it will not be valid to evaluate that expression using an unordered SQL query. Morel needs some means of specifying whether order is important.It's very likely that the
from
expression will work over any monad (list, set, relation). If there is a single input, or if all the inputs are the same kind of monad, then the output would be the same kind.Ideally Morel would recognize these patterns and convert to relational algebra. But I also hope that programmers become accustomed to writing in the more concise “relational” manner, even if they intend to run the program locally. Do you have any patterns in mind? It would be useful to start a list.
Yes, Calcite is good at hybrid planning. It will consider local joins if the data sources are distinct.
The text was updated successfully, but these errors were encountered: