forked from hydromatic/morel
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MOREL-159] from should not have a singleton record type unless it en…
…ds with a singleton record yield If a `from` expression has one variable named `i` of type `int`, should the type of the returned elements be `int` or `{i: int}`? (We call `int` a scalar, `{i: int}` a singleton record type, `yield {i = i}` a singleton record yield, and `yield {i = j, j = k}` a renaming yield.) After this change, `from` will have a singleton record type only it ends with a singleton record yield. If it does not end in yield, the type depends on N, the number of pipeline variables, and will be a scalar if N = 1 and a record with N fields if N != 1. As part of this change, we introduce a new `class FromBuilder` to safely build `Core.From` pipelines. It performs micro-optimizations as it goes, such as removing `where true`, empty `order` and trivial `yield` steps. `FromBuilder` can also inline nested from expressions: from i in (from j in [1, 2, 3] where j > 1) where i < 3 becomes from j in [1, 2, 3] where j > 1 yield {i = j} where i < 3 Note the use of `yield {i = j}` to handle the variable name change caused by inlining. Ensure that `from d in scott.depts` is not printed as '<relation>' even if it is optimized to `scott.depts`. If we write `scott.depts` in the shell, the shell prints '<relation>' because `depts` may be a large table. `FromBuilder` now simplies `from d in scott.depts` to `scott.depts`, but we want the shell to print the rows, not '<relation>'. Therefore the shell now calls `Code.wrap` to tag whether an expression would be treated as a relation or as a query. Fixes hydromatic#159
- Loading branch information
1 parent
b6aa372
commit bc82150
Showing
14 changed files
with
912 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.