feat!: require explict database references#4223
Conversation
|
I've tried a few different ways to implement the special case name-resolving behavior of So I give up of trying to make this behavior work and am instead removing it. I don't accept this PR to be merged as it has arguably worse aesthetics than what we had before. If it doesn't I don't mind, but I would continue to develop a fork of PRQL as my pet language. As @max-sixty pointed out the other day, current state of prqlc is such that most things work, but when you get off the beaten track, things start to break with weird error messages. I attribute this to the fact that we have a few "hackish" parts of the codebase, which are necessary for a few features that I consider "inconsistent with the rest of the language". It is probably possible to make these feature work correctly, but I don't have the motivation to spend enormous amounts of time to do that. |
Can we discuss more?1 Happy to speak this week on Discord. You're contributed more to PRQL than anyone, and so your view should have a huge weight. I do think it would be a shame for both PRQL and PRQL-pet-lang — one would lose most of its code momentum, and the other would lose most of its community momentum. Projects really need both to be successful. I accept we've been a bit stuck for a while, without the user momentum we'd expect from the community + code momentum. I admittedly don't get the If we're looking for smaller changes interface changes which achieve the same goal, could we restrict
If we think we can't get PRQL to be robust with the current strategy and we need to make bigger changes, there are things we could do to restrict the scope and make it more robust. For example at the extreme, we could force having a schema in order to compile PRQL. This would be a big change, and would significantly reduce its flexibility, but it would also have the potential to become really robust in the short-medium term. (And it wouldn't completely preclude us from removing this constraint in the future) Footnotes
|
|
Thank you for the enormous amount of work and consideration on these. However, I feel that there is a better alternative to the database than |
|
Mentioning the word "fork" was probably not very wise of me :D Please understand my frustration when rewriting the name resolution for the 3rd time and hitting a wall again. Of course we can talk about what to do about the issue of In practical terms for PRQL, this means that in this example: ... variable Currently this does not hold, as the example above would report a missing error for My solution is simple: require the module name in all table references. In the example above, that would mean this: ... because (This is the required part, now follows what can easily be changed) To make this more ergonomic:
But this is not the only way, we could have: ... or ... |
Totally, no stress my end. And to reiterate — sometimes saying the extreme thing is the way to get change! It's often underrated, particularly when others aren't listening well enough.
Yes, good point. If we really have to choose something in the list above, I would vote for:
I think the natural question from this is — "but why not just assume the I think the answer is — "because we want to resolve the In thinking through this, I'm less opposed to it than I was. I do feel like we lose some of the beautiful simplicity that drew people in to PRQL. But plausibly prefixing Two hail-marys before we make the change:
I really don't get the If we also want to drop from foo # nice to have each line starting with a transform
derive (bar = baz + 5)
...etc...or we're a more complicated language with variables and custom functions, like: let foo = # some table definition
let bar = # some function
foo | bar # lines aren't starting with transforms anyway |
Exactly, well explained.
I think you are right, we it would not help much. Ideally, name resolution would happen before and independent of type resolution. It would be weird that adding a type annotation would make some name point to completely different variable.
Yup, it wouldn't solve this issue.
Looking at code examples with
I'm not opposed to it either. It is unnecessary, but it does look nice: from db.x
join db.y
into a
from a... as opposed to: db.x
join db.y
into a
aOk, I'll update this PR to "alternative 2". |
|
Another thing: |
|
I'm in favour of "alternative 2" as well.
I agree with the name resolution reasons discussed above (although I'm not really qualified to comment on them the explanations do make sense), but more importantly for me (given that I mostly wear the "Advanced User" rather than "Compiler Engineer" hat), I think it improves the user experience as well. In particular it makes it clearer what are database tables/views and what are derived relations. I was going to add an example for this but Aljaz has already provided the perfect one: from db.x
join db.y
into a
from aI think this nicely separates derived relation
I would strongly prefer to keep the from x=db.long_legacy_system_table_name
join y=db.other_long_legacy_system_table_name
...What would that be without x=db.long_legacy_system_table_name
join y=db.other_long_legacy_system_table_name
...but then one might think shouldn't that have a let x=db.long_legacy_system_table_name
join y=db.other_long_legacy_system_table_name
...Where would the alias go with the x=from.my_table
...but that has the same |
|
Of course aliasing could be solved with separate from x=db.long_legacy_system_table_name
join y=db.other_long_legacy_system_table_name
...with let x=db.long_legacy_system_table_name
x
join y=db.other_long_legacy_system_table_name
...And what about role playing aliases, e.g. let employee=employees
employee
join manager=employees (employee.manager_id==manager.id)
...Again, I think the following is much better: from employee=employees
join manager=employees (employee.manager_id==manager.id) |
415dd6e to
857de65
Compare
e03689e to
091256a
Compare
|
I'll help clear this up We should run |
This reverts commit 3dcace7.
This PR removes
std.fromand renamesdefault_dbmodule tofrom. This is the effect: