cube2222 / octosql

OctoSQL is a query tool that allows you to join, analyse and transform data from multiple databases and file formats using SQL.
Mozilla Public License 2.0
4.76k stars 200 forks source link

why two map object in the logical nodes? #206

Closed mei-rune closed 4 years ago

mei-rune commented 4 years ago

I write a graphviz tool for octosql https://github.com/cube2222/octosql/issues/203

And I try convert "select a, b, c from abc as xxx" to a image file.

octosql

why two map object in the logical nodes?

cube2222 commented 4 years ago

The crux is keep: true and keep: false.

The first one creates any new expressions (in a map for example) keeping the old ones. This way a filter node has access to all the fields. New ones and old ones. (you can do SELECT p.age + 5 as newage FROM people p WHERE newage > p.age).

Then you have a second map node, which will only leave the necessary fields. (the ones the user selected).

Indeed, in your case the first one is unnecessary, but that could be added to the optimizer as a new optimization rule in the future and is not really that important imo.

mei-rune commented 4 years ago

Thinks