Skip to content

Support sub-aggregation queries (correlated subqueries with GROUP BY) for Relation Function Class Mappings#4844

Merged
aziemchawdhary-gs merged 93 commits into
finos:masterfrom
Vithesh-Reddy:master
Jun 19, 2026
Merged

Support sub-aggregation queries (correlated subqueries with GROUP BY) for Relation Function Class Mappings#4844
aziemchawdhary-gs merged 93 commits into
finos:masterfrom
Vithesh-Reddy:master

Conversation

@Vithesh-Reddy

Copy link
Copy Markdown
Contributor

Relation Function Class Mappings currently lack primary key (PK) support, which is required for union mappings, graph fetch, and sub-aggregation queries (e.g., correlated subqueries with GROUP BY). This work adds end-to-end PK support across the compiler stack: Grammar, Parser, Composer, Compiler (prerequisite elements pass + third pass), and Pure inference logic.
Primary keys can be explicitly declared via ~primaryKey syntax or auto-inferred where possible — for example, when the relation function body uses a direct table accessor (#>{my::db.personTable}#), the PK is inferred from the underlying table's primary key. An extension-based architecture (RelationElementAccessorExtension) enables PK inference for SQL expressions (#SQL{...}#) and other store-specific relation sources without coupling modules.
API/Grammar Design:
Single PK: ~primaryKey: ID Multiple PKs: ~primaryKey: [ID, FIRMID] Auto-inferred (no declaration needed): ~func my::personFunc_Relation_1 where the function body resolves to a table accessor

Vithesh-Reddy and others added 11 commits May 29, 2026 11:49
…feature-class_to_relation-subagg_pk-support

# Conflicts:
#	legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/ClassMappingPrerequisiteElementsPassBuilder.java
#	legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/mapping/RelationFunctionMappingParseTreeWalker.java
#	legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/parser/TestMappingGrammarParser.java
#	legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/packageableElement/mapping/relationFunction/RelationFunctionClassMapping.java
#	legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/mapping/relationFunctionMapping.pure
#	legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/legend-engine-xt-relationalStore-core-pure/src/main/resources/core_relational/relational/helperFunctions/helperFunctions.pure
…ure-class_to_relation-subagg_pk-support

# Conflicts:
#	legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/parser/TestMappingGrammarParser.java
Support sub-aggregation queries (correlated subqueries with GROUP BY) for Relation Function Class Mappings
@Vithesh-Reddy Vithesh-Reddy requested a review from a team as a code owner June 12, 2026 05:39
gs-rpant1729
gs-rpant1729 previously approved these changes Jun 12, 2026
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

Test Results

  1 109 files    1 109 suites   3h 25m 2s ⏱️
14 487 tests 14 308 ✔️ 179 💤 0
37 704 runs  37 525 ✔️ 179 💤 0

Results for commit 430c627.

♻️ This comment has been updated with latest results.

@gs-rpant1729

Copy link
Copy Markdown
Contributor

LGTM

@aziemchawdhary-gs aziemchawdhary-gs merged commit 7d5a4df into finos:master Jun 19, 2026
52 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants