Comments (5)
Hi @SilverEzhik — thanks a lot for the full and thoughtful issue
I'll answer as much as I can now and please let me know if I miss anything:
-
Definitely this takes inspiration from the ML world. So the pipe is one way of calling a function. Specifically, these three are equivalent:
# 1. x | lag_day # 2. lag_day x # 3. ( x lag_day )
-
The use of is_valid_price bugs me a lot as it's not actually in scope of the function. What would happen if it was called on a table that didn't have that column?
Good question. You can think of a column name like
is_valid_price
as either an identifier than needs to be in scope, or a constant. The existing code works if it's considered a constant which doesn't require scope. If it's required to be in scope, it would make functions much less useful — every column name would need to be passed into every function, IIUC. And in PRQL, column names are just strings to us, they're not representing anything more abstract that we need to bind to. Can you think of a case where the current approach would cause any ambiguity in the transpilation? -
FWIW at least in OCaml,
x | foo(a, b, c)
is equivalent tofoo(a, b, c, x)
(note the different in location of thex
from above):# let f x y = (x * 10) + y;; val f : int -> int -> int = <fun> # let g = 1 |> f;; (* g now equals (10 + y), because 1 binds to the first arg *) val g : int -> int = <fun> # 2 |> g ;; - : int = 12
So that's the current design of PRQL; first bullet here
-
I agree re the issues with boolean logic and infix operators. I discuss some of the tradeoffs in "Thinking about". I'm open to ideas and approaches there.
-
I tend to agree re the ternary operator. We need to figure out how we transpile to SQL's
if ... then
andcase
so we have a single approach and uses common keywords in a consistent way. -
I agree with your views on single vs double quotes, and the raw sql tradeoffs. Backticks are good. One issue is that they conflict with markdown — someone copies a line into a markdown file and then needs to escape it, and f-strings have been really successful. So that's another area we can think about and iterate on.
We can open issues on any of the final three items if people would like to discuss them.
Thanks @SilverEzhik
from prql.
Can you think of a case where the current approach would cause any ambiguity in the transpilation?
If PRQL functions are mapped to SQL functions, wouldn't scope become a problem? Or is the plan to have these functions essentially be macros that get substituted into the translated SQL?
One potential fix would be to require scoping functions inside the query:
from some_table
func foo x = ... # foo has access to columns of some_table
join other_table ... # but not to columns of other_table
Thinking about it, this probably doesn't matter if PRQL is just getting compiled into SQL, but if it was aware of the table schema, this could be used to catch errors before the query gets translated.
from prql.
Probably a silly question , but for the pipe syntax of x | some_func , how do you pass two parameters to the function, x,y | some_func ?
but if it was aware of the table schema, this could be used to catch errors before the query gets translated.
Oh man, that would be amazing.
from prql.
how do you pass two parameters to the function, x,y | some_func ?
Piping can only pass one arg, so that would be y | some_func x
or some_func x y
.
but if it was aware of the table schema, this could be used to catch errors before the query gets translated.
I'll try and write something up on this around a roadmap — it seems like there's lots of excitement around it. It's much much harder than the current plan, but would follow on nicely, assuming we can execute on the current plan.
from prql.
I think these have been answered or covered elsewhere. It was an excellent set of issues!
Please keep them coming @SilverEzhik & @qorrect .
from prql.
Related Issues (20)
- Nightly tests failed
- Parentheses omitted from sql output in non-commutative operations HOT 8
- Nightly tests failed HOT 1
- Name of the type for UTF-8 encoded strings of textual data HOT 4
- Top with group on Postgres HOT 5
- `std.prql` module HOT 2
- Modules containing data (tables, relations) HOT 3
- Release plan for 0.11.1 HOT 2
- Nightly tests failed HOT 1
- Remove `std.prql_version` in favor of `std.prql.version` HOT 5
- Nightly tests failed HOT 4
- Grouping breaks `select * except` HOT 2
- Set up text "fixture" for CLI project tests
- Clickhouse DATETIME conversion invalid format HOT 4
- Zig tests started failing HOT 3
- The various exit status codes from `prqlc` HOT 2
- Python compiler needs a flag to return the full sequence of errors as json HOT 5
- Compiler panic with `sort` in inline join relation HOT 5
- Nightly tests failed HOT 1
- `**` operator (or something else) for `math.pow` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prql.