如何在 aws 上使用 python3 嵌套地图属性的过滤器表达式?

How to use filter expressions on aws using python3 for nested map attribute?

我一直在尝试扫描 DynamoDB 以检查名为 deliverables 的嵌套映射属性中的特定值。但是,使用带有过滤器表达式的扫描会导致空结果。

import boto3
result = []
dynamo_client = boto3.client("dynamodb")
paginator = dynamo_client.get_paginator("scan")

operation_parameters = {
    'FilterExpression': "#Deliverable= :deliverable",
    'ExpressionAttributeNames': {
        '#Deliverable': 'deliverables.fc986523-a666-478e-8303-2a1c3c1dc4ba'
    },
    'ExpressionAttributeValues': {
    ':deliverable':  {
    "M": {
     "read": {
      "BOOL": True
     },
     "upload": {
      "BOOL": True
     },
     "write": {
      "BOOL": True
     }
    }
    }
  }
}
for page in paginator.paginate(TableName="TableName", **operation_parameters):
    result.append(page["Items"])

print(result)

dynamo 数据库中的项目如下所示:

[
   [
      {
         "deliverables":{
            "M":{
               "7397d832-fefb-4ba2-97a1-0f6e73d611d9":{
                  "M":{
                     "read":{
                        "BOOL":true
                     },
                     "upload":{
                        "BOOL":true
                     },
                     "write":{
                        "BOOL":true
                     }
                  }
               },
               "fc986523-a666-478e-8303-2a1c3c1dc4ba":{
                  "M":{
                     "read":{
                        "BOOL":true
                     },
                     "upload":{
                        "BOOL":true
                     },
                     "write":{
                        "BOOL":true
                     }
                  }
               }
            }
         },
         "username":{
            "S":"username1"
         },
         "deniedReferences":{
            "L":[
               
            ]
         }
      },
      {
         "deliverables":{
            "M":{
               "7397d832-fefb-4ba2-97a1-0f6e73d611d9":{
                  "M":{
                     "read":{
                        "BOOL":true
                     },
                     "upload":{
                        "BOOL":false
                     },
                     "write":{
                        "BOOL":false
                     }
                  }
               },
               "fc986523-a666-478e-8303-2a1c3c1dc4ba":{
                  "M":{
                     "read":{
                        "BOOL":true
                     },
                     "upload":{
                        "BOOL":false
                     },
                     "write":{
                        "BOOL":false
                     }
                  }
               }
            }
         },
         "username":{
            "S":"repositoryadmin"
         },
         "deniedReferences":{
            "L":[
               
            ]
         }
      }
   ]
]

如果你能帮我解决这个问题,请告诉我。

问题是这里的[点]:'ExpressionAttributeNames': { '#Deliverable': 'deliverables.fc986523-a666-478e-8303-2a1c3c1dc4ba'}

Expressions docs: DynamoDB interprets a dot in an expression attribute name as a character within an attribute's name.

operation_parameters = {
    "FilterExpression": "#D0.#D1=:deliverable", # the dot goes here!
    "ExpressionAttributeNames": {
        "#D0": "deliverables",
        "#D1": "fc986523-a666-478e-8303-2a1c3c1dc4ba"
    },