News for hackers. Stuff that matters.
Re:Why I Turned Down an AWS Job Offer by oarabbus_ on Monday August 05, 2019 @02:33PM (#20616949)
I simplified the ask to be honest. It was not a simple `select date, country, sum(gdp) from table group by 1,2`. There were additional components to the question.

And as you mentioned, you can also distinct on the window function. This is not an inefficient operation in Redshift.

Also I fundamentally disagree with your premise. One result set is equivalent to another, and as long as you aren't using unnecessary nested loop joins or such, there are a dozen ways to solve a query.

In another interview at a similarly-competitive company to AWS , I was asked to do some work on orders and orderdetail tables to find all customers where the aggregate total of their orders from 2005 were greater than that of their orders from 2007. I did it using a couple of `sum(case when extract(year from datecol) = 200x then order_amount end)` statements.

The interviewer told me the question was intended to test whether the applicant was able to do a self-join but they were impressed with my alternative solution. That is the proper way to test SQL, not to say someone "did the query the wrong way"

Re:Why I Turned Down an AWS Job Offer by jaf656s on Monday August 05, 2019 @03:18PM (#20617637)
>One result set is equivalent to another, and as long as you aren't using unnecessary nested loop joins or such, there are a dozen ways to solve a query.

If they consume similar resources I'd almost always opt for the simplest one to understand.

In cases where the simpler one is less efficient, I might still use it if the task didn't require absolute optimization.

Re:Why I Turned Down an AWS Job Offer by SilasX on Monday August 05, 2019 @06:13PM (#20619667)
Sure, and that would be a fair criticism, to say, "is there a version of this that's more intuitive and easier to read with the same load on the server?" But the interviewer (assuming the OP faithfully represented the exchange and the domain) is insisting that the query does not do what was asked -- when it does -- and is saying so based on the interviewer's own incomplete understanding.

That's not a good reason to reject a candidate, even if there might be other good reasons in this case.

Re:Why I Turned Down an AWS Job Offer by oarabbus_ on Monday August 05, 2019 @07:23PM (#20620331)
Exactly, it would have been fair game to ask why I used a window function instead of an aggregate function + subquery joined back onto the main result set. Or, to ask if I could rewrite the query another way which would be more efficient.

However, the interviewer didn't simply insist the query does not do what was asked (when it did indeed return the correct results).

Instead, the interviewer actually insisted it was an invalid query which would not run at all.

Re:Why I Turned Down an AWS Job Offer by jaf656s on Monday August 05, 2019 @07:41PM (#20620482)
In this case it sounds like a bad interview and that they missed a good opportunity for discussion!
Re:Why I Turned Down an AWS Job Offer by socialist_coder on Monday August 05, 2019 @11:53PM (#20621982)
From their perspective, they have hundreds of candidates and need to quickly filter a bunch out. So, having low-technical knowledge recruiters ask questions and look for a standard set of answers is the way they do it. There is no room for technical discussion during this phase, no room for nuance.

I'm not saying this is a good process or that it's fair, but it is the reality right now. You still get OK results and it's far faster and cheaper.

Re:Why I Turned Down an AWS Job Offer by oarabbus_ on Tuesday August 06, 2019 @12:33AM (#20622153)
I’d already passed the recruiter screen and another phone interview. This was the technical interview with the manager of the group.
Re:Why I Turned Down an AWS Job Offer by socialist_coder on Tuesday August 06, 2019 @09:04AM (#20624744)
oh wow, damn. that is pretty sad.
Re:Why I Turned Down an AWS Job Offer by jaf656s on Monday August 05, 2019 @07:40PM (#20620466)
You're exactly right wrt interviewing. I was talking in general and not in the context of an interview.

If you are interviewing someone and they solve the problem you ask, and then you don't give them some sort of guidance or constraints to meet your "correct" guidelines, then you aren't doing a good and fair interview.