question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Query with grouping columns but no aggregate ignores column aliases

See original GitHub issue

If a query has grouping columns but no aggregates the aliases are ignored. To reproduce start the quick start batch and run the following query:

select AtBatting as foo, baseOnBalls as bar from baseballStats 
group by AtBatting, baseOnBalls
limit 10

Result uses AtBatting and baseOnBalls instead of foo, bar

If an aggregate is added then the aliases are correct:

select AtBatting as foo, baseOnBalls as bar , count(*) from baseballStats 
group by AtBatting, baseOnBalls
limit 10

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
SandishKumarHNcommented, Oct 11, 2021

working on it

1reaction
Jackie-Jiangcommented, Nov 10, 2021

Fixed by #7678

Read more comments on GitHub >

github_iconTop Results From Across the Web

7 Common GROUP BY Errors - LearnSQL.com
1. Forgetting GROUP BY with Aggregate Functions ... You use SELECT statements with the GROUP BY clause when you want to group and...
Read more >
Using GROUP BY and JOIN-ing non-aggregated columns to ...
Maybe by aggregating the extra columns? SELECT foo, bar, baz, moo , MAX(ins_date) AS mdate ... Or join to the grouped fields and...
Read more >
Selecting Ungrouped Columns Without Aggregate Functions
We'll call columns/expressions that are in SELECT without being in an aggregate function, nor in GROUP BY , barecolumns. In other words, if...
Read more >
Aggregating and Grouping Data
COUNT and GROUP BY ... Aggregation allows us to combine results by grouping records based on value. It is also useful for calculating...
Read more >
B.3.4.4 Problems with Column Aliases
Standard SQL disallows references to column aliases in a WHERE clause. This restriction is imposed because when the WHERE clause is evaluated, the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found