We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
In 'from' clause, allow initializers to reference previous variables. For example:
from word in ["hello", "world"], c in String_explode word yield c;
The initializer of c is String_explode word, which references the word variable defined in the outer loop.
c
String_explode word
word
In SQL, this is a called a lateral join.
SQL example 1. Use the LATERAL keyword to signal that a sub-query in the FROM clause can reference other variables:
LATERAL
FROM
SELECT * FROM orders AS o, LATERAL (SELECT * FROM lineItems AS i WHERE i.orderId = o.id)
Note that the sub-query references o. Without LATERAL, that would be illegal.
o
SQL example 2. The UNNEST function is implicitly lateral:
UNNEST
SELECT * FROM orders AS o, LATERAL UNNEST(o.lineItems) AS i
SQL example 3. Use the CROSS APPLY syntax to call a table function, again, implicitly lateral:
CROSS APPLY
SELECT * FROM emps AS e CROSS APPLY findDependents(e.empno)
Should we use an efficient implementation, so that if the initializer does not reference previous variables, it is evaluated at the start?
No. If the user wants that efficiency, they can assign the initializer to a variable. For example, in
from i in String_explode "abc", j in String_explode "xy";
i's initializer String_explode "abc" should be called once, and j's initializer String_explode "xy" should be called 3 times. But in
i
String_explode "abc"
j
String_explode "xy"
from i in String_explode "", j in String_explode "xy";
i's initializer String_explode "" should be called once, and j's initializer String_explode "xy" should be called 0 times. In
String_explode ""
let val i0 = String_explode "abc" val j0 = String_explode "xy" in from i in i0, j in j0 end
each String_explode is evaluated once.
String_explode
The text was updated successfully, but these errors were encountered:
Fixed in 7397c39.
Sorry, something went wrong.
No branches or pull requests
In 'from' clause, allow initializers to reference previous variables. For example:
The initializer of
c
isString_explode word
, which references theword
variable defined in the outer loop.Comparison with SQL
In SQL, this is a called a lateral join.
SQL example 1. Use the
LATERAL
keyword to signal that a sub-query in theFROM
clause can reference other variables:Note that the sub-query references
o
. WithoutLATERAL
, that would be illegal.SQL example 2. The
UNNEST
function is implicitly lateral:SQL example 3. Use the
CROSS APPLY
syntax to call a table function, again, implicitly lateral:Efficient implementation?
Should we use an efficient implementation, so that if the initializer does not reference previous variables, it is evaluated at the start?
No. If the user wants that efficiency, they can assign the initializer to a variable. For example, in
i
's initializerString_explode "abc"
should be called once, andj
's initializerString_explode "xy"
should be called 3 times. But ini
's initializerString_explode ""
should be called once, andj
's initializerString_explode "xy"
should be called 0 times. Ineach
String_explode
is evaluated once.The text was updated successfully, but these errors were encountered: