Issue 47: Query expression planner now recognises GSIs (#48)
The query expression planner now recognises GSIs, and will use them if the expression can be executed as a query over an index.
This commit is contained in:
parent
7caf905c82
commit
733e59ec95
15 changed files with 190 additions and 163 deletions
|
|
@ -15,6 +15,7 @@ import (
|
|||
|
||||
type TestData struct {
|
||||
TableName string
|
||||
Index []string
|
||||
Data []map[string]interface{}
|
||||
}
|
||||
|
||||
|
|
@ -31,7 +32,7 @@ func SetupTestTable(t *testing.T, testData []TestData) *dynamodb.Client {
|
|||
dynamodb.WithEndpointResolver(dynamodb.EndpointResolverFromURL("http://localhost:4566")))
|
||||
|
||||
for _, table := range testData {
|
||||
_, err = dynamoClient.CreateTable(ctx, &dynamodb.CreateTableInput{
|
||||
tableInput := &dynamodb.CreateTableInput{
|
||||
TableName: aws.String(table.TableName),
|
||||
KeySchema: []types.KeySchemaElement{
|
||||
{AttributeName: aws.String("pk"), KeyType: types.KeyTypeHash},
|
||||
|
|
@ -45,7 +46,28 @@ func SetupTestTable(t *testing.T, testData []TestData) *dynamodb.Client {
|
|||
ReadCapacityUnits: aws.Int64(100),
|
||||
WriteCapacityUnits: aws.Int64(100),
|
||||
},
|
||||
})
|
||||
}
|
||||
for _, index := range table.Index {
|
||||
tableInput.AttributeDefinitions = append(tableInput.AttributeDefinitions, types.AttributeDefinition{
|
||||
AttributeName: aws.String(index),
|
||||
AttributeType: types.ScalarAttributeTypeS,
|
||||
})
|
||||
tableInput.GlobalSecondaryIndexes = append(tableInput.GlobalSecondaryIndexes, types.GlobalSecondaryIndex{
|
||||
IndexName: aws.String(index + "-index"),
|
||||
KeySchema: []types.KeySchemaElement{
|
||||
{AttributeName: aws.String(index), KeyType: types.KeyTypeHash},
|
||||
},
|
||||
Projection: &types.Projection{
|
||||
ProjectionType: types.ProjectionTypeAll,
|
||||
},
|
||||
ProvisionedThroughput: &types.ProvisionedThroughput{
|
||||
ReadCapacityUnits: aws.Int64(100),
|
||||
WriteCapacityUnits: aws.Int64(100),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
_, err = dynamoClient.CreateTable(ctx, tableInput)
|
||||
assert.NoError(t, err)
|
||||
|
||||
for _, item := range table.Data {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue