Issues/Questions and Decisions

Issue/QuestionDecisionNotes
What is the proposed approach to be used in CPS? Do we use the approach as per postgREST where the REST queries are executed directly as database queries without the need of any ORM?
As per an exchange on Slack, we are not going with the postgREST model. And instead stick to using the cps-ri layer as it is? https://onapproject.slack.com/archives/C03UJAZAV3K/p1711714427478109
The proposal says the query parameter will look something like this ?select=name, price.gt.100. But in the postgREST documentation we can see that things like name and price are considered columns in a data base while in this proposal these are mentioned as leaf data node. I don't think ?select=name, price.gt.100 will be possible and instead we need to work with the jsonb objects and use arrow operators,- >, as mentioned in postGREST. But then again, the use of arrow operator is possible when we are directly executing queries at database level.

If we are going to use the cps-ri layer as it is then what approach needs to be implemented to search for a particular leaf node under a data node? Need to finalize this.

postgREST implements operators that are translated to SQL queries, for example "eq" translated to =. How do we implement these operators in our approach?

Objective

CPS query API can be further improved to support more generic query parameters or request parameters where we can provide request input like JSON and that will be parsed to SQL query. these parameters are optional and provides more generic approach to query from large data. 

So, we are proposing to use generic SQL query like request parameters along with cps-path for enhanced query operations. these parameters will be parsed to SQL statement for query operation.

API changes

Query Data nodes API will be enhanced with extra optional query parameter

API: GET http://<IP>:<PORT>/cps/v2/dataspaces/{dataspace-name}/anchor/{anchor-name}/nodes/query?select={generic_query_parameter}

Query parameters.

Parameter NameObjectiveExamples
selectTo query only selected fields for a given cps-path. 

?select=title, price

?select=name, price.gt.100

Use cases.

  1. We want to query data nodes and get only selected few leaves. It will help to limit the output data and also in searching if a leaf in present in a data node or not. 
  2. Search of a specific leaf without knowing actual cps-path. If a client is not sure about the cps-path but he wants to query for a given leaf node

Implementation Proposal

References

Tables and Views — PostgREST 12.0 documentation

  • No labels

2 Comments

  1. Rajesh kumar 

    So this concept will be used along with the xpath or its just either xpath or the sql-query parameter??

  2. Hi Priyank Maheshwari this concept will work with cps-path. so, cps-path will be used for query along with additional query parameter