refactor: simplify functions in the "hoist from selected fields" process
This commit is contained in:
@@ -703,14 +703,12 @@ hoistFromSelectFields relAggAlias fields =
|
|||||||
let (modifiedField, maybeAgg) = modifyField field
|
let (modifiedField, maybeAgg) = modifyField field
|
||||||
in (modifiedField : newFields, maybeAgg : aggList)
|
in (modifiedField : newFields, maybeAgg : aggList)
|
||||||
|
|
||||||
modifyField field =
|
modifyField field@CoercibleSelectField{csAggFunction=Just aggFunc, csField, csAggCast, csAlias} =
|
||||||
case csAggFunction field of
|
let determineFieldName = fromMaybe (cfName csField) csAlias
|
||||||
Just aggFunc ->
|
updatedField = field {csAggFunction = Nothing, csAggCast = Nothing}
|
||||||
( field { csAggFunction = Nothing, csAggCast = Nothing },
|
hoistedField = Just ((relAggAlias, determineFieldName), (aggFunc, csAggCast, csAlias))
|
||||||
Just ((relAggAlias, determineFieldName field), (aggFunc, csAggCast field, csAlias field)))
|
in (updatedField, hoistedField)
|
||||||
Nothing -> (field, Nothing)
|
modifyField field = (field, Nothing)
|
||||||
|
|
||||||
determineFieldName field = fromMaybe (cfName $ csField field) (csAlias field)
|
|
||||||
|
|
||||||
-- Taking the hoisted aggregates, modify the rel selects to apply the aggregates,
|
-- Taking the hoisted aggregates, modify the rel selects to apply the aggregates,
|
||||||
-- and any applicable casts or aliases.
|
-- and any applicable casts or aliases.
|
||||||
|
|||||||
Reference in New Issue
Block a user