Skip to content

Commit 2b01bbf

Browse files
committed
add showcase for Relation Function class mappings
1 parent 0157fe4 commit 2b01bbf

File tree

2 files changed

+82
-195
lines changed
  • showcases/data/End To End Examples/Relation Function Class Mapping

2 files changed

+82
-195
lines changed

showcases/data/End To End Examples/Relation Function Class Mapping/code.pure

Lines changed: 79 additions & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -43,199 +43,11 @@ Database showcase::relationFunctionMapping::store::Database
4343
)
4444

4545

46-
###Service
47-
Service showcase::relationFunctionMapping::service::SimpleService
48-
{
49-
pattern: '/5e1615e2-f153-4b3e-baee-878f51dfa25a';
50-
ownership: DID { identifier: '' };
51-
documentation: '';
52-
autoActivateUpdates: true;
53-
execution: Single
54-
{
55-
query: |showcase::relationFunctionMapping::domain::Firm.all()->project(
56-
[
57-
x|$x.legalName,
58-
x|$x.employees.firstName,
59-
x|$x.employees.age
60-
],
61-
[
62-
'Legal Name',
63-
'Employees/First Name',
64-
'Employees/Age'
65-
]
66-
);
67-
mapping: showcase::relationFunctionMapping::mapping::SimpleMapping;
68-
runtime: showcase::relationFunctionMapping::runtime::Runtime;
69-
}
70-
testSuites:
71-
[
72-
testSuite_1:
73-
{
74-
data:
75-
[
76-
connections:
77-
[
78-
connection_1:
79-
Reference
80-
#{
81-
showcase::relationFunctionMapping::TestData
82-
}#
83-
]
84-
]
85-
tests:
86-
[
87-
test_1:
88-
{
89-
serializationFormat: PURE_TDSOBJECT;
90-
asserts:
91-
[
92-
assertion_1:
93-
EqualToJson
94-
#{
95-
expected:
96-
ExternalFormat
97-
#{
98-
contentType: 'application/json';
99-
data: '[\n {\n "Legal Name": "Firm X",\n "Employees/First Name": "Peter",\n "Employees/Age": 23\n },\n {\n "Legal Name": "Firm X",\n "Employees/First Name": "John",\n "Employees/Age": 30\n },\n {\n "Legal Name": "Firm A",\n "Employees/First Name": "Jane",\n "Employees/Age": 23\n },\n {\n "Legal Name": "Firm B",\n "Employees/First Name": "Anthony",\n "Employees/Age": 19\n },\n {\n "Legal Name": "Firm C",\n "Employees/First Name": "Fabrice",\n "Employees/Age": 45\n },\n {\n "Legal Name": "Firm C",\n "Employees/First Name": "Oliver",\n "Employees/Age": 26\n },\n {\n "Legal Name": "Firm D",\n "Employees/First Name": "David",\n "Employees/Age": 52\n }\n]';
100-
}#;
101-
}#
102-
]
103-
}
104-
]
105-
}
106-
]
107-
}
108-
109-
Service showcase::relationFunctionMapping::service::ComplexService
110-
{
111-
pattern: '/0b2bf7d8-e7e2-424e-8755-70974496adda';
112-
ownership: DID { identifier: '' };
113-
documentation: '';
114-
autoActivateUpdates: true;
115-
execution: Single
116-
{
117-
query: |showcase::relationFunctionMapping::domain::ComplexPerson.all()->project(
118-
[
119-
x|$x.age,
120-
x|$x.rank,
121-
x|$x.salary
122-
],
123-
[
124-
'Age',
125-
'Rank',
126-
'Salary'
127-
]
128-
);
129-
mapping: showcase::relationFunctionMapping::mapping::ComplexMapping;
130-
runtime: showcase::relationFunctionMapping::runtime::Runtime;
131-
}
132-
testSuites:
133-
[
134-
testSuite_1:
135-
{
136-
data:
137-
[
138-
connections:
139-
[
140-
connection_1:
141-
Reference
142-
#{
143-
showcase::relationFunctionMapping::TestData
144-
}#
145-
]
146-
]
147-
tests:
148-
[
149-
test_1:
150-
{
151-
serializationFormat: PURE_TDSOBJECT;
152-
asserts:
153-
[
154-
assertion_1:
155-
EqualToJson
156-
#{
157-
expected:
158-
ExternalFormat
159-
#{
160-
contentType: 'application/json';
161-
data: '[\n {\n "Age": 23,\n "Rank": 1,\n "Salary": 14.34\n },\n {\n "Age": 30,\n "Rank": 2,\n "Salary": 72.4\n },\n {\n "Age": 23,\n "Rank": 1,\n "Salary": 48.0\n },\n {\n "Age": 19,\n "Rank": 1,\n "Salary": 64.9\n },\n {\n "Age": 45,\n "Rank": 1,\n "Salary": 19.29\n },\n {\n "Age": 26,\n "Rank": 2,\n "Salary": 42.34\n },\n {\n "Age": 52,\n "Rank": 1,\n "Salary": 88.88\n }\n]';
162-
}#;
163-
}#
164-
]
165-
}
166-
]
167-
}
168-
]
169-
}
170-
171-
Service showcase::relationFunctionMapping::service::MixedService
172-
{
173-
pattern: '/46b251f5-93fc-4e97-a723-2c984cbc5ba0';
174-
ownership: DID { identifier: '' };
175-
documentation: '';
176-
autoActivateUpdates: true;
177-
execution: Single
178-
{
179-
query: |showcase::relationFunctionMapping::domain::Person.all()->project(
180-
[
181-
x|$x.age,
182-
x|$x.firstName,
183-
x|$x.firm.legalName
184-
],
185-
[
186-
'Age',
187-
'First Name',
188-
'Firm/Legal Name'
189-
]
190-
);
191-
mapping: showcase::relationFunctionMapping::mapping::MixedMapping;
192-
runtime: showcase::relationFunctionMapping::runtime::Runtime;
193-
}
194-
testSuites:
195-
[
196-
testSuite_1:
197-
{
198-
data:
199-
[
200-
connections:
201-
[
202-
connection_1:
203-
Reference
204-
#{
205-
showcase::relationFunctionMapping::TestData
206-
}#
207-
]
208-
]
209-
tests:
210-
[
211-
test_1:
212-
{
213-
serializationFormat: PURE_TDSOBJECT;
214-
asserts:
215-
[
216-
assertion_1:
217-
EqualToJson
218-
#{
219-
expected:
220-
ExternalFormat
221-
#{
222-
contentType: 'application/json';
223-
data: '[\n {\n "Age": 23,\n "First Name": "Peter",\n "Firm/Legal Name": "Firm X"\n },\n {\n "Age": 30,\n "First Name": "John",\n "Firm/Legal Name": "Firm X"\n },\n {\n "Age": 23,\n "First Name": "Jane",\n "Firm/Legal Name": "Firm A"\n },\n {\n "Age": 19,\n "First Name": "Anthony",\n "Firm/Legal Name": "Firm B"\n },\n {\n "Age": 45,\n "First Name": "Fabrice",\n "Firm/Legal Name": "Firm C"\n }\n]';
224-
}#;
225-
}#
226-
]
227-
}
228-
]
229-
}
230-
]
231-
}
232-
233-
23446
###Text
23547
Text showcase::relationFunctionMapping::README
23648
{
23749
type: markdown;
238-
content: 'This showcase demonstrates how to write Relation Function Class Mappings. \n\nThis allows you to map classes to functions returning a \'new\' TDS (Relation). Supported class properties can only be primitives \nhaving multiplicity 1 and get mapped to individual columns in the mapped relation.\n\nQueries can also use a mixture of Relational and Relation Function class mappings.\n\nYour relation expression can contain complex joins, aggregates and window columns, thus providing a more powerful alternative to \nRelational Store views.\n\nYou can execute the service tests to see how all of this works end-to-end. You can also generate plan for the services and inspect \nthe generated SQL.';
50+
content: 'This showcase demonstrates how to write Relation Function Class Mappings. \n\nThis allows you to map classes to functions returning a \'new\' TDS (Relation). Supported class properties can only be primitives \nhaving multiplicity 1 and get mapped to individual columns in the mapped relation.\n\nQueries can also use a mixture of Relational and Relation Function class mappings.\n\nYour relation expression can contain complex joins, aggregates and window columns, thus providing a more powerful alternative to \nRelational Store views.\n\nYou can execute the function tests to see how all of this works end-to-end. You can also generate plan for the functions and inspect \nthe generated SQL.';
23951
}
24052

24153

@@ -309,6 +121,84 @@ function showcase::relationFunctionMapping::function::complexPersonFunction(): m
309121
)
310122
}
311123

124+
function showcase::relationFunctionMapping::query::complexQuery(): meta::pure::tds::TabularDataSet[1]
125+
{
126+
showcase::relationFunctionMapping::domain::ComplexPerson.all()->project(
127+
[
128+
x|$x.age,
129+
x|$x.rank,
130+
x|$x.salary
131+
],
132+
[
133+
'Age',
134+
'Rank',
135+
'Salary'
136+
]
137+
)->from(
138+
showcase::relationFunctionMapping::mapping::ComplexMapping,
139+
showcase::relationFunctionMapping::runtime::Runtime
140+
)
141+
}
142+
{
143+
test
144+
(
145+
showcase::relationFunctionMapping::store::Database: showcase::relationFunctionMapping::TestData;
146+
test | complexQuery() => (JSON) '[\n {\n "Age": 23,\n "Rank": 1,\n "Salary": 14.34\n },\n {\n "Age": 30,\n "Rank": 2,\n "Salary": 72.4\n },\n {\n "Age": 23,\n "Rank": 1,\n "Salary": 48.0\n },\n {\n "Age": 19,\n "Rank": 1,\n "Salary": 64.9\n },\n {\n "Age": 45,\n "Rank": 1,\n "Salary": 19.29\n },\n {\n "Age": 26,\n "Rank": 2,\n "Salary": 42.34\n },\n {\n "Age": 52,\n "Rank": 1,\n "Salary": 88.88\n }\n]';
147+
)
148+
}
149+
150+
function showcase::relationFunctionMapping::query::simpleQuery(): meta::pure::tds::TabularDataSet[1]
151+
{
152+
showcase::relationFunctionMapping::domain::Firm.all()->project(
153+
[
154+
x|$x.legalName,
155+
x|$x.employees.firstName,
156+
x|$x.employees.age
157+
],
158+
[
159+
'Legal Name',
160+
'Employees/First Name',
161+
'Employees/Age'
162+
]
163+
)->from(
164+
showcase::relationFunctionMapping::mapping::SimpleMapping,
165+
showcase::relationFunctionMapping::runtime::Runtime
166+
)
167+
}
168+
{
169+
test
170+
(
171+
showcase::relationFunctionMapping::store::Database: showcase::relationFunctionMapping::TestData;
172+
test | simpleQuery() => (JSON) '[\n {\n "Legal Name": "Firm X",\n "Employees/First Name": "Peter",\n "Employees/Age": 23\n },\n {\n "Legal Name": "Firm X",\n "Employees/First Name": "John",\n "Employees/Age": 30\n },\n {\n "Legal Name": "Firm A",\n "Employees/First Name": "Jane",\n "Employees/Age": 23\n },\n {\n "Legal Name": "Firm B",\n "Employees/First Name": "Anthony",\n "Employees/Age": 19\n },\n {\n "Legal Name": "Firm C",\n "Employees/First Name": "Fabrice",\n "Employees/Age": 45\n },\n {\n "Legal Name": "Firm C",\n "Employees/First Name": "Oliver",\n "Employees/Age": 26\n },\n {\n "Legal Name": "Firm D",\n "Employees/First Name": "David",\n "Employees/Age": 52\n }\n]';
173+
)
174+
}
175+
176+
function showcase::relationFunctionMapping::query::mixedQuery(): meta::pure::tds::TabularDataSet[1]
177+
{
178+
showcase::relationFunctionMapping::domain::Person.all()->project(
179+
[
180+
x|$x.age,
181+
x|$x.firstName,
182+
x|$x.firm.legalName
183+
],
184+
[
185+
'Age',
186+
'First Name',
187+
'Firm/Legal Name'
188+
]
189+
)->from(
190+
showcase::relationFunctionMapping::mapping::MixedMapping,
191+
showcase::relationFunctionMapping::runtime::Runtime
192+
)
193+
}
194+
{
195+
testSuite
196+
(
197+
showcase::relationFunctionMapping::store::Database: showcase::relationFunctionMapping::TestData;
198+
test | mixedQuery() => (JSON) '[\n {\n "Age": 23,\n "First Name": "Peter",\n "Firm/Legal Name": "Firm X"\n },\n {\n "Age": 30,\n "First Name": "John",\n "Firm/Legal Name": "Firm X"\n },\n {\n "Age": 23,\n "First Name": "Jane",\n "Firm/Legal Name": "Firm A"\n },\n {\n "Age": 19,\n "First Name": "Anthony",\n "Firm/Legal Name": "Firm B"\n },\n {\n "Age": 45,\n "First Name": "Fabrice",\n "Firm/Legal Name": "Firm C"\n }\n]';
199+
)
200+
}
201+
312202

313203
###Mapping
314204
Mapping showcase::relationFunctionMapping::mapping::SimpleMapping

showcases/data/End To End Examples/Relation Function Class Mapping/info.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@ Description: End-to-End example for writing Relation Function Class Mappings
55

66
This showcase demonstrates how to write Relation Function Class Mappings.
77

8-
This allows you to map classes to functions returning a 'new' TDS (Relation). Supported class properties can only be primitives
9-
having multiplicity 1 and get mapped to individual columns in the mapped relation.
8+
This allows you to map classes to functions returning a 'new' TDS (Relation). Supported class properties can only be primitives having multiplicity 1 and get mapped to individual columns in the mapped relation.
109

1110
Queries can also use a mixture of Relational and Relation Function class mappings.
1211

13-
Your relation expression can contain complex joins, aggregates and window columns, thus providing a more powerful alternative to
14-
Relational Store views.
12+
Your relation expression can contain complex joins, aggregates and window columns, thus providing a more powerful alternative to Relational Store views.
1513

16-
You can execute the service tests to see how all of this works end-to-end. You can also generate plan for the services and inspect
17-
the generated SQL.
14+
You can execute the function tests to see how all of this works end-to-end. You can also generate plan for the functions and inspect the generated SQL.

0 commit comments

Comments
 (0)