Hacker News new | ask | show | jobs
by boramalper 2076 days ago
I would reorder round and square brackets, since I may want to filter on computed/created columns, and the ordering makes it clearer.
2 comments

It's up to you (and the query optimizer can reorder), but you have to make sure the column is available when you use it. Broken up:

I had:

    a = employee(name == "Jones")    a has name, salary and age

    w = a[comp = salary / (age - 18)]   w has comp
You want:

    b = employee[name, comp = salary / (age - 18)]   b has name and comp

    w = b(name == "Jones" && comp > 500)   w has name and comp
In one line:

    w = employee[name, comp = salary / (age - 18)](name == "Jones" && comp > 500)
I'm not sure if you misunderstood them or I misunderstood you, but there's no legitimate reason you can't filter on computed columns as is:

  w = employee(name == "Jones")[comp = salary / (age - 18)](comp > 2000)