Earlier quoted context omitted.
SELECT id, name, author Quick, what is this query about? What's ironic is that I think you have it backwards: the columns are the implementation detail, not the table. The table is the context: you can't change that without having to change everything else. But columns are the last step, the selection after the filters, joins, etc. They can be changed at any time without affecting the logic.
This is... An odd choice. I'd assume I'm not without context looking at a query to know why I would want those columns. And the auto complete story is backwards. Often I know what columns I want, but I'm not clear what table I need to get them from. Such that, if you make a smarter suggest in the from to only include tables that have the columns, I'd be much happier.
PRQL – A proposal for a better SQL
171–180 of 302 posts
Re: PRQL – A proposal for a better SQL
#172\tangent What are today's data transformation needs (differ from Codd's inspiration?), how does relational algebra serve them, and design an "SQL" around that. There's got to be a 10x leapfrog in benefit for some niche in there, and that's the gateway to adoption.
Re: PRQL – A proposal for a better SQL
#173I'm quite opposed to the idea "from should be first". I want to understand what exactly the query returns, not the implementation detail of the source of this data (that can later be changed). Literally first example from page - I have no idea what is being returned: from employees filter country = "USA" # Each line transforms the previous result. let gross_salary = salary + payroll_tax # This _adds_ a column / varia…
While it inherently feels unnatural I do agree with the others here that the context is actually easier to understand once over the initial uncomfort.
Re: PRQL – A proposal for a better SQL
#174SQL could get a lot better by just adopting the ordering of operations like they did with LINQ: https://docs.microsoft.com/en-us/dotnet/csharp/programming-g...
Funnily enough LINQ Query syntax is really uncommon and everybody uses method syntax var list = new List {1,2,3} var extracted = list ....................Where(x => x > 1) ....................Select(x => $"my number: {x}) ....................ToList();
Not everybody
Re: PRQL – A proposal for a better SQL
#175what data do i want to see: most important
where doest is come from: next most important thing
What filters and restrictions am i going to put on it: least important
Re: PRQL – A proposal for a better SQL
#176Earlier quoted context omitted.
This is... An odd choice. I'd assume I'm not without context looking at a query to know why I would want those columns. And the auto complete story is backwards. Often I know what columns I want, but I'm not clear what table I need to get them from. Such that, if you make a smarter suggest in the from to only include tables that have the columns, I'd be much happier.
Just throwing in another point of anecdata onto this pile: "Often I know what columns I want, but I'm not clear what table I need to get them from" does not make sense to me. I don't relate at all to their being a global namespace of columns, rather than a namespace of tables, each with its own columns specific to its context.
I further assert that if your database is filled with "Id" and "name" columns, instead of "department_name" and similar, you are probably as likely to mess up a join as any benefit you get from the name being short. (And really, what advantage is there in short names nowadays?)
That all said. I worded my take too strongly. My point should have been that auto suggest should not be confined in either direction.
Re: PRQL – A proposal for a better SQL
#177This is another in a series of these kinds of proposals that look excellent on first glance for perhaps the 75% case but start getting syntactically messy when I want to customize the resultset returned. On the surface, they're always neat but when you start to dig into how you'd implement something in an RDBMS, it begins to fall apart. Let's look at the example syntax: from employees filter country = "USA" # Each li…
"Each line transforms the previous result." - I assume this is referring to the order that transpilation happens, so you can read it top to bottom and understand the flow easily.
One thing I would like to see is how a recursive CTE might look.
Re: PRQL – A proposal for a better SQL
#178Earlier quoted context omitted.
With a CTE it would read a bit more like prql: with usa_employees as ( SELECT title, country, salary, (salary + payroll_tax) AS gross_salary, (salary + payroll_tax + healthcare_cost) AS gross_cost FROM employees WHERE country = 'USA' AND (salary + payroll_tax + healthcare_cost) > 0 ) select title, country, AVG(salary) AS average_salary, SUM(salary) AS sum_salary, AVG(gross_salary) AS average_gross_salary, SUM(gross_s…
what expressions are being repeated here?
> (salary + payroll_tax + healthcare_cost) AS gross_cost
> AND (salary + payroll_tax + healthcare_cost) > 0
And his is a simple example.
Re: PRQL – A proposal for a better SQL
#179I like the flow direction compared to standard SQL. SQL is supposed to read like a sentence I suppose but I have many times looked at it and really wanted things to be in a more logical order. My main suggestion would be to be a bit less terse and introduce a bit more firm formatting. I'm not a huge fan of the term "split" and feel like jazzing that up to "split over" or even just reviving "group by" would improve re…
I like the flow direction specifically for intellisense/autocomplete. I'm sure it would be easier to provide hints when the table name is known immediately.
Re: PRQL – A proposal for a better SQL
#180I like the flow direction compared to standard SQL. SQL is supposed to read like a sentence I suppose but I have many times looked at it and really wanted things to be in a more logical order. My main suggestion would be to be a bit less terse and introduce a bit more firm formatting. I'm not a huge fan of the term "split" and feel like jazzing that up to "split over" or even just reviving "group by" would improve re…
Hallelujah! But, to your footnote, this is a major reason why I despise ORMs. In my mind they make writing simple code slightly easier, but they make complicated SQL statements, especially when you get some weird issue under load and you're trying to debug why your DB is falling over, a ton more difficult and you spend so much time just battling your ORM.