Skip to content

Commit

Permalink
Added "ConcatDistinct" as new aggregate type
Browse files Browse the repository at this point in the history
  • Loading branch information
darkfrog26 committed Jun 11, 2024
1 parent ac65581 commit c6368f1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ val developerURL: String = "https://matthicks.com"

name := projectName
ThisBuild / organization := org
ThisBuild / version := "0.11.0-SNAPSHOT"
ThisBuild / version := "0.11.0-SNAPSHOT1"
ThisBuild / scalaVersion := scala213
ThisBuild / crossScalaVersions := allScalaVersions
ThisBuild / scalacOptions ++= Seq("-unchecked", "-deprecation")
Expand Down
1 change: 1 addition & 0 deletions core/src/main/scala/lightdb/aggregate/AggregateType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ object AggregateType {
case object CountDistinct extends AggregateType
case object Group extends AggregateType
case object Concat extends AggregateType
case object ConcatDistinct extends AggregateType
}
1 change: 1 addition & 0 deletions core/src/main/scala/lightdb/index/Index.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ trait Index[F, D <: Document[D]] extends FilterSupport[F, D, Filter[D]] {
lazy val countDistinct: AggregateFunction[Int, F, D] = AggregateFunction(s"${fieldName}CountDistinct", this, AggregateType.CountDistinct)
lazy val group: AggregateFunction[F, F, D] = AggregateFunction(s"${fieldName}Group", this, AggregateType.Group)
lazy val concat: AggregateFunction[List[F], F, D] = AggregateFunction(s"${fieldName}Concat", this, AggregateType.Concat)(Index.ConcatRW)
lazy val concatDistinct: AggregateFunction[List[F], F, D] = AggregateFunction(s"${fieldName}ConcatDistinct", this, AggregateType.ConcatDistinct)(Index.ConcatRW)

def aggregateFilterSupport(name: String): FilterSupport[F, D, AggregateFilter[D]]
}
Expand Down
4 changes: 2 additions & 2 deletions sql/src/main/scala/lightdb/sql/SQLSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,13 @@ trait SQLSupport[D <: Document[D]] extends IndexSupport[D] {
case AggregateType.Avg => Some("AVG")
case AggregateType.Sum => Some("SUM")
case AggregateType.Count | AggregateType.CountDistinct => Some("COUNT")
case AggregateType.Concat => Some("GROUP_CONCAT")
case AggregateType.Concat | AggregateType.ConcatDistinct => Some("GROUP_CONCAT")
case AggregateType.Group => None
}
val fieldName = af match {
case Some(s) =>
val pre = f.`type` match {
case AggregateType.CountDistinct => "DISTINCT "
case AggregateType.CountDistinct | AggregateType.ConcatDistinct => "DISTINCT "
case _ => ""
}
val post = f.`type` match {
Expand Down

0 comments on commit c6368f1

Please sign in to comment.