Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing sorting in count distinct aggregation #1077

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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