awslabs / dynein

DynamoDB CLI written in Rust.
https://github.com/awslabs/dynein
Apache License 2.0
360 stars 37 forks source link

Query command against GSI does not display GSI's primary keys in column #221

Open StoneDot opened 4 months ago

StoneDot commented 4 months ago

Currently, query command against GSI does not display GSI's primary keys and only shows base table primary keys.

Current behavior

❯ dy desc
name: zero-etl-opensearch
region: us-west-2
status: ACTIVE
schema:
  pk: pk (S)
  sk: sk (S)
mode: Provisioned
capacity:
  wcu: 1
  rcu: 1
gsi:
- name: pk-gsi1-index
  schema:
    pk: pk (S)
    sk: gsi1 (S)
  capacity:
    wcu: 1
    rcu: 1
lsi: null
stream: null
count: 0
size_bytes: 0
created_at: 2024-05-05T08:42:29+00:00

❯ dy query --index pk-gsi1-index B001TOQ8J8
pk          sk                      attributes
B001TOQ8J8  q#Tx37RU99WFIJWIR#meta  {"question_text":"Is this 1st or 3d person view?",...
B001TOQ8J8  q#Tx2Y72JHW1Y1YNG#meta  {"question_type":"WH","gsi1":"q#qt#WH","question_t...
B001TOQ8J8  q#Tx28ZVOED5GOL1C#meta  {"question_type":"yes-no","question_text":"Can you...
B001TOQ8J8  q#Tx1W4DS0L22WOW0#meta  {"gsi1":"q#qt#yes-no","question_text":"Is this the...
B001TOQ8J8  q#TxBE62XOV5GDXN#meta   {"gsi1":"q#qt#yes-no","question_text":"can you pla...
B001TOQ8J8  q#TxR7GGCCSRK57C#meta   {"question_text":"does it have a regional compatib...
B001TOQ8J8  q#Tx269YJS2EDQJS1#meta  {"question_type":"yes-no","gsi1":"q#qt#yes-no","qu...
B001TOQ8J8  q#Tx39IVDF6JEK0ZZ#meta  {"gsi1":"q#qt#yes-no","question_type":"yes-no","qu...
B001TOQ8J8  q#Tx12IZ3FXZVJ0NB#meta  {"gsi1":"q#qt#yes-no","question_type":"yes-no","qu...
B001TOQ8J8  q#Tx2E185VOGZLO8H#meta  {"question_type":"yes-no","gsi1":"q#qt#yes-no","qu...
B001TOQ8J8  q#Tx58ZPUBOLXS03#meta   {"gsi1":"q#qt#yes-no","question_text":"Can this be...

Suggested behavior

I think the preferred order is GSI partition key, GSI sort key, table partition key and table sort key. Additionally, we should avoid duplication.

❯ dy query --index pk-gsi1-index B001TOQ8J8
pk          gsi1         sk                      attributes
B001TOQ8J8  q#qt#WH      q#Tx37RU99WFIJWIR#meta  {"question_text":"Is this 1st...
B001TOQ8J8  q#qt#WH      q#Tx2Y72JHW1Y1YNG#meta  {"question_type":"WH","questi...
B001TOQ8J8  q#qt#yes-no  q#Tx28ZVOED5GOL1C#meta  {"question_type":"yes-no","qu...
B001TOQ8J8  q#qt#yes-no  q#Tx1W4DS0L22WOW0#meta  {"question_text":"Is this the...
B001TOQ8J8  q#qt#yes-no  q#TxBE62XOV5GDXN#meta   {"question_text":"can you pla...
B001TOQ8J8  q#qt#yes-no  q#TxR7GGCCSRK57C#meta   {"question_text":"does it hav...
B001TOQ8J8  q#qt#yes-no  q#Tx269YJS2EDQJS1#meta  {"question_type":"yes-no","qu...
B001TOQ8J8  q#qt#yes-no  q#Tx39IVDF6JEK0ZZ#meta  {"question_type":"yes-no","qu...
B001TOQ8J8  q#qt#yes-no  q#Tx12IZ3FXZVJ0NB#meta  {"question_type":"yes-no","qu...
B001TOQ8J8  q#qt#yes-no  q#Tx2E185VOGZLO8H#meta  {"question_type":"yes-no","qu...
B001TOQ8J8  q#qt#yes-no  q#Tx58ZPUBOLXS03#meta   {"question_text":"Can this be...