PRQL / prql

PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement
https://prql-lang.org
Apache License 2.0
9.93k stars 217 forks source link

Refining the type of pipelines #3026

Open not-my-profile opened 1 year ago

not-my-profile commented 1 year ago

Pipelines are currently just Vec<Expr>:

https://github.com/PRQL/prql/blob/d7b2401b9cc4cbef54eb88851983bca8464b7eaa/crates/prql_ast/src/expr.rs#L118-L122

I think having Expr for the initial value and Vec<FuncCall> for the transformations would make sense? However I am not so sure since the parser for some reason (?) also passes lambda_func(), which returns a Func (function definition), to pipeline() ... I am not sure what's going on there ... 890bd84723c8d322129a4d6b24bd621446cb1a77 introduced this:

   -        let nested_expr = pipeline(func_call(expr.clone())).boxed();
   +        let nested_expr = pipeline(lambda_func(expr.clone()).or(func_call(expr.clone()))).boxed();
aljazerzen commented 1 year ago

On the syntactic level, they might be plain Idents and not FuncCalls:

let take_one = func rel -> (take 1)

from table_a
take_one

Here, take_one is just an ident, that resolves into a closure.

aljazerzen commented 1 year ago

If this makes sense, feel free to close.

For future questions, you can use Discord or the GH discussions.