Skip to content

Conversation

@vim89
Copy link
Owner

@vim89 vim89 commented Sep 22, 2025

Add comprehensive COUNT aggregation support addressing issue com-lihaoyi#95:

  • Add AggAnyOps.scala with count/countDistinct for Expr[T] types
  • Add countBy/countDistinctBy methods to AggOps.scala
  • Full cross-database compatibility (PostgreSQL, MySQL, SQLite, H2, MS SQL)
  • Proper NULL handling (COUNT ignores NULL values, COUNT(*) counts all)
  • Support for expressions: map(...).count, map(...).countDistinct
  • Multi-dialect SQL generation with proper operator precedence
  • Comprehensive test coverage including edge cases and complex expressions

Features:

  • .countBy(_.column) generates COUNT(column) SQL
  • .countDistinctBy(_.column) generates COUNT(DISTINCT column) SQL
  • .count/.countDistinct on mapped expressions for advanced scenarios
  • Works with arithmetic expressions, filters, group by, and joins
  • Consistent API design matching existing aggregation functions

  Add comprehensive COUNT aggregation support addressing issue com-lihaoyi#95:

  - Add AggAnyOps.scala with count/countDistinct for Expr[T] types
  - Add countBy/countDistinctBy methods to AggOps.scala
  - Full cross-database compatibility (PostgreSQL, MySQL, SQLite, H2, MS SQL)
  - Proper NULL handling (COUNT ignores NULL values, COUNT(*) counts all)
  - Support for expressions: map(...).count, map(...).countDistinct
  - Multi-dialect SQL generation with proper operator precedence
  - Comprehensive test coverage including edge cases and complex expressions

  Features:
  - .countBy(_.column) generates COUNT(column) SQL
  - .countDistinctBy(_.column) generates COUNT(DISTINCT column) SQL
  - .count/.countDistinct on mapped expressions for advanced scenarios
  - Works with arithmetic expressions, filters, group by, and joins
  - Consistent API design matching existing aggregation functions
@vim89 vim89 merged commit b8676a5 into main Sep 22, 2025
@vim89 vim89 deleted the feat-count-agg branch September 22, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants