Ujjawal Kumar created PHOENIX-8081:
--------------------------------------

             Summary: Support for querying the shared view index table
                 Key: PHOENIX-8081
                 URL: https://issues.apache.org/jira/browse/PHOENIX-8081
             Project: Phoenix
          Issue Type: New Feature
            Reporter: Ujjawal Kumar


Phoenix stores indexes created on child views in a shared physical view-index 
table, but it does not provide a SQL construct to query rows across all those 
indexes. 

A caller can query an individual logical index,but cannot discover which 
base-table primary keys are represented in any view index or check whether a 
particular primary key has view-index data. 

Add a fixed-schema SQL relation exposing the columns common to every shared 
view-index row: 

- VIEW_INDEX_ID 
- VIEW_NAME 
- INDEX_NAME 
- All base-table primary-key columns 

Index-specific indexed and included columns are out of scope. Salt remains an 
internal Phoenix detail. 

### Generic SQL example 


CREATE TABLE S.BASE_TABLE ( 
TENANT_ID VARCHAR NOT NULL, 
ENTITY_TYPE VARCHAR NOT NULL, 
CREATED_AT DATE, 
CONSTRAINT PK PRIMARY KEY (TENANT_ID, ENTITY_TYPE) 
) 
MULTI_TENANT = true; 


Proposed syntax: 


SELECT * 
FROM VIEW_INDEXES(S.BASE_TABLE); 


For this table, SELECT * returns: 


VIEW_INDEX_ID 
VIEW_NAME 
INDEX_NAME 
TENANT_ID 
ENTITY_TYPE 


CREATED_AT is not returned because it is not part of the base-table primary key 
and is not guaranteed to exist in every view index. 

Additional example queries:  


-- Find all tenants represented in any view index 
SELECT DISTINCT TENANT_ID 
FROM VIEW_INDEXES(S.BASE_TABLE); 

-- Check whether a tenant has any view-index data 
SELECT 1 
FROM VIEW_INDEXES(S.BASE_TABLE) 
WHERE TENANT_ID = ? 
LIMIT 1; 


VIEW_INDEXES(...) is illustrative syntax; the final syntax can differ while 
preserving these semantics.  



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to