apache / apache/openwhisk

Remove legacy query support for subjects in SubjectViewMapper for CosmosDB

Open
#4,639 0 comments 0 reactions 1 assignee Claimed by @chetanmeh View on GitHub
cosmosdb
Dominant language
Scala
Stars
6.8k
Forks
1.2k
Avg merge
2d 14h
Merged PRs (30d)
2

Description

#4638 removes support for legacy view from subject. Per this change subjects would not be queries on the basis of `uuid` and `key` at top level document and instead would be **always** queried on the basis of keys within sub docs under `namespaces` field.

Per that change following changes are needed on CosmosDB side

## Remove unnecessary indexes

We currently have indexes for top level fields like `/uuid`, `/subject`. These can be removed

https://github.com/apache/openwhisk/blob/4dd17971d6c19f0aee1dcf5e19d14643e42bf993/common/scala/src/main/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBViewMapper.scala#L250-L261

## Simplify queries

The queries used

https://github.com/apache/openwhisk/blob/4dd17971d6c19f0aee1dcf5e19d14643e42bf993/common/scala/src/main/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBViewMapper.scala#L291-L308

Have clauses to query for top level fields

```sql
SELECT r AS VIEW
FROM root r
JOIN n IN r.namespaces
WHERE
(NOT(is_defined(r.blocked)) OR r.blocked = falses)
AND (
(r.uuid = @uuid AND r.KEY = @key)
OR (n.uuid = @uuid AND n.KEY = @key)
)
```

Here we can simplify the `AND` clause

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.