-
Notifications
You must be signed in to change notification settings - Fork 116
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
Add support for TDS v2 (relation) groupBy in QueryBuilder #3892
Conversation
…ling nested properties
🦋 Changeset detectedLatest commit: 495c377 The changes in this PR will be included in the next version bump. This PR includes changesets to release 31 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…ateBuilder functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job! The tests and general flow are very comprehensive.
I left some minor comments, mostly on some edge cases handling and code organization.
} from '@finos/legend-graph'; | ||
import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../graph/QueryBuilderMetaModelConst.js'; | ||
|
||
export const getNumericAggregateOperatorReturnType = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move away from having methods like this:
- It doesn't really save you much time code writing, we don't use this anywhere else other than within the operator
- The operator code is supposed to be modular, the current flow favors organizing the handling logic for the operator within the same file as the operator rather than dispersing them in classifier method like this ~~ think about why we don't have a giant method with big switch cases to handle all operators but have each file for one operator, the same logic holds true in that case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! I removed the function and also removed us trying to manually get the column's return type when we convert from protocol to a SimpleFunctionExpression
. Instead, we now update the groupBy()
expression's return type when we process the graph here: https://github.com/finos/legend-studio/pull/3892/files#diff-2e5035c76b375d2a795ff0ba9a702405c2dec6dc4e0aabc1d115c63e659db6e3R144
...-query-builder/src/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.ts
Outdated
Show resolved
Hide resolved
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_GROUP_BY, | ||
) | ||
QUERY_BUILDER_SUPPORTED_FUNCTIONS.RELATION_GROUP_BY, | ||
]) | ||
) { | ||
return V1_buildGroupByFunctionExpression( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So an edge case, let's pass the functionName
to V1_buildGroupByFunctionExpression
When the functionName is fully specified, i.e. meta::pure::tds::groupBy
or meta::pure::functions::relation::groupBy
we also know exactly what to handle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. functionName
was already passed to V1_buildGroupByFunctionExpression
, but now in V1_buildGroupByFunctionExpression
I check if functionName === QUERY_BUILDER_SUPPORTED_FUNCTIONS.RELATION_GROUP_BY
and call V1_buildTypedGroupByFunctionExpression
if that is true.
...rc/stores/fetch-structure/tds/aggregation/operators/QueryBuilderAggregateOperator_Average.ts
Outdated
Show resolved
Hide resolved
this.queryBuilderState, | ||
this.parentLambda, | ||
); | ||
if (isTypedGroupByExpression(valueSpecification)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment here, we should be careful of the case where people specify the fully specified function path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I updated isTypedGroupByExpression
to first check if expression.functionName === QUERY_BUILDER_SUPPORTED_FUNCTIONS.RELATION_GROUP_BY
. I also updated the isTypedProjectionExpression
function to do the same.
…unctionExpression
…tionColSpec function
Summary
Add support for using the new TDS v2 (relation) protocol with groupBy expressions. This includes
groupBy
functions (i.e., count, sum, etc.)groupBy
functions to QueryBuilder stateHow did you test this change?
Group by:

Group by with multiple columns:

Group by with pre-filter:

Group by with post-filter:

Group by with pre-filter and post-filter:
