Can i know reason for below error
View cannot be projected into result type:
- Projected field [middle_name1] with type [string] not found in result type [au.com.westpac.blsop.domain.view.EligiblePartyMessageResponse]
- Projected field [first_name] with type [string] not found in result type [au.com.westpac.blsop.domain.view.EligiblePartyMessageResponse]
- Projected field [middle_name2] with type [string] not found in result type [au.com.westpac.blsop.domain.view.EligiblePartyMessageResponse]
- Projected field [middle_name3] with type [string] not found in result type [au.com.westpac.blsop.domain.view.EligiblePartyMessageResponse]
- Projected field [last_name] with type [string] not found in result type [au.com.westpac.blsop.domain.view.EligiblePartyMessageResponse]
…
message EligiblePartyMessageResponse {
repeated EligibleParty eligible_party = 1;
}
message EligibleParty{
string middle_name1 = 1;
string first_name = 2;
string middle_name2 = 3;
string middle_name3 = 4;
string last_name = 5;
}
rpc GetEligiblePartyDetails(google.protobuf.Empty) returns (EligiblePartyMessageResponse) {
option (kalix.method).view.query = {
query: "SELECT party.middle_name1,party.first_name,party.middle_name2,party.middle_name3,party.last_name FROM party WHERE party.party_role.description = ‘Individual’ "
};
option (google.api.http) = {
get: “/party/GetEligiblePartyDetails”
};
}
}
Hi @parmitkr,
There is indeed something odd here.
It seems that the EligiblePartyMessageResponse
is being used as the stored type, while it should be EligibleParty
.
Also, in none of the two message there is a field for party_role
. So I guess there is another proto message in play here.
Could you share the whole file?
@octonato
Party_role is another object in state
message PartyState {
au.com.westpac.blsop.framework.message.Lifecycle lifecycle = 1;
string party_id = 2;
PartyRole party_role = 3;
}
Please, share the whole file so we can better analyse it.
Hi @parmitkr,
The response type for the message is:
message EligiblePartyMessageResponse {
repeated EligibleParty eligible_party = 1;
}
But the query is trying to project the EligibleParty
fields directly into that message with:
SELECT party.middle_name1,party.first_name,party.middle_name2,party.middle_name3,party.last_name
As the error message says, none of those fields can be found in EligiblePartyMessageResponse
, as they’re nested within the repeated eligible_party
field.
You’ll need specify the structure by grouping these fields together (with parentheses) and projecting into the repeated field with an alias:
SELECT (party.middle_name1,party.first_name,party.middle_name2,party.middle_name3,party.last_name) AS eligible_party
Some examples in the docs for this, under relational projection:
Assuming those fields are actually in the PartyState
that’s being stored in the view.
If you have a different structure, sharing all the definitions would be useful.
The SELECT
lets you project from the state messages to a different response message, and can work with nested structures on either side.
Thanks for your reply it worked.
@pvlugter i was trying to write a union query but getting error is union available if not what is the alternative
SELECT (middle_name1,first_name,middle_name2,middle_name3,last_name) AS eligible_party FROM party WHERE party_role.description = ‘Individual’ UNION SELECT (middle_name1,first_name,middle_name2,middle_name3,last_name) AS eligible_party FROM party WHERE party_role.description = ‘Company’
UNION
is not supported in the view query language currently.
You can express a union on the same table with OR
. For the same field you can use IN
.
But I believe those may currently still be disabled by default for indexing reasons. Please open a support ticket and we can remove the restriction for a particular service, and show you how to do that locally. And we can remove this restriction by default in the next release.
You could then express this query using:
SELECT (middle_name1,first_name,middle_name2,middle_name3,last_name) AS eligible_party
FROM party
WHERE party_role.description IN ('Individual', 'Company')
Thanks But i want to add mutiple filter in WHERE for each query ,IN will not resolve my issue.
Ok, you’ll be able to use OR
for union-like queries for the same table but different fields in the filter.