Skip to content

Commit

Permalink
Merge pull request #1077 from Cryptonomic/bugfix/fixing-sorting-in-co…
Browse files Browse the repository at this point in the history
…unt-distinct-aggregation

Fixing sorting in count distinct aggregation
  • Loading branch information
SiddharthV1 authored Jan 31, 2022
2 parents 82b63b0 + 75e17ec commit 9dbc6f8
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,25 @@ object DataTypes {
val in, between, like, lt, gt, eq, startsWith, endsWith, before, after, isnull = Value
}

/** Helps with changing camel case to snake case */
object StringHelper {

/** Helper regex */
private val separatees = "[a-z](?=[A-Z])|[0-9](?=[a-zA-Z])|[A-Z](?=[A-Z][a-z])|[a-zA-Z](?=[0-9])".r

/** Helper method for converting camel case to snake case */
def camel2Snake(s: String): String = separatees.replaceAllIn(s, _.group(0) + '_').toLowerCase
}


/** Enumeration of aggregation functions */
object AggregationType extends Enumeration {


/** Helper method for extracting prefixes needed for SQL */
def prefixes: List[String] = values.toList.map(_.toString + "_")
def prefixes: List[String] = values.toList.map(x => StringHelper.camel2Snake(x.toString) + "_")
type AggregationType = Value
val sum, count, max, min, avg, countDistinct = Value
val countDistinct, sum, count, max, min, avg = Value
}

/** Enumeration of aggregation functions */
Expand Down

0 comments on commit 9dbc6f8

Please sign in to comment.