nom-sql icon indicating copy to clipboard operation
nom-sql copied to clipboard

Move alias up to FieldExpression

Open ekmartin opened this issue 7 years ago • 6 comments

This makes the FieldExpression a struct with an alias field, with the old FieldExpression nested under as a Field (naming ideas welcome), and removes alias from Column and ArithmeticExpression.

This would be a breaking change and would require some refactoring in distributary, but I thought I'd check if you think this is the right approach first.

ekmartin avatar Feb 28 '18 14:02 ekmartin

This would make it impossible to have nested aliases in one expression, but I can't think of any usecases where that would make a difference (e.g. ((foo AS a) / (bar AS b)) AS c or something, but with the inner aliases actually mattering?).

ekmartin avatar Feb 28 '18 14:02 ekmartin

@ms705: saw that you added aliases to Literal in https://github.com/ms705/nom-sql/commit/2b3f18809dad08687452e1b584a3e8a8b7d45bd7. If you think that is a better approach in general I'll close this :) I guess it'd be useful to eventually be able to do SELECT * AS everything ... too though?

ekmartin avatar Mar 13 '18 18:03 ekmartin

Oh, duh -- I missed this PR. Will take a look to see if your solution is better than mine (which was a quick hack to get a query to work). Sorry about that!

ms705 avatar Mar 13 '18 18:03 ms705

No worries, but let me know and I'll rebase. It does also change existing behavior slightly (see https://github.com/ms705/nom-sql/pull/15#discussion_r171262574) so probably requires some thought nonetheless.

ekmartin avatar Mar 13 '18 18:03 ekmartin

I think this approach is cleaner than what we currently have, but it's quite disruptive as it breaks any code that uses Column, which is a lot. Hence, I propose we shelve it until after the OSDI deadline, and then rebase and merge when we're not fighting fires. Sounds ok?

ms705 avatar Mar 25 '18 19:03 ms705

Yep - that definitely sounds reasonable!

ekmartin avatar Mar 25 '18 19:03 ekmartin