Kumar Gaurav created CAMEL-22029: ------------------------------------ Summary: aws dynamodb scan an query not implemented with attributes-to-get and projection and filter expressions Key: CAMEL-22029 URL: https://issues.apache.org/jira/browse/CAMEL-22029 Project: Camel Issue Type: Improvement Components: camel-aws Affects Versions: 4.4.5 Environment: Affected versions 4.4.5 and above. It shall be released as part of new LTS release.
Thing is - Camel dynamodb component still based on legacy aws parameters. IT shall be upgraded to use/support new parameters. Reporter: Kumar Gaurav {*}Context{*}: 1- QUERY operation: Users want to query the data using key column only to bring all the attributes related to items with that key. However, Camel DynamoDB component makes it mandatory to send attributes-to-get. 2- Scan operation: users want to scan a DynamoDB table and return only a *subset of attributes.* However, aws-camel-sdk for DynamoDB does not support this parameter. {*}Problem{*}: QUERY - aws-sdk has a validation that if attribute-to-get is being passed it cannot have 0 items. therefore, we are getting an exception as ddb component always adds this attributes with zero items if it is not supplied from kamelet. SCAN - We need to fix _ScanCommand_ class of camel-aws-ddb lib to support his operation which is already supported by aws-sdk for dynamodab . {*}Solution{*}: Modify the class and refactor the below code to send attribute-to-get only if it is provided by customer. If it is not supplied (header '' is empty or null), this parameter shall not be sent as part of ddb query request object. *As an iHub developer* - I want to modify the camel aws-ddb-component query request code and release it as hotfix. *For reference:* [*AttributesToGet*|https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html#API_Query_RequestSyntax] This is a legacy parameter. Use {{ProjectionExpression}} instead. For more information, see [AttributesToGet|https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.AttributesToGet.html] in the {_}Amazon DynamoDB Developer Guide{_}. Type: Array of strings Array Members: Minimum number of 1 item. Length Constraints: Maximum length of 65535. Required: No The legacy conditional parameter {{AttributesToGet}} is an array of one or more attributes to retrieve from DynamoDB. If no attribute names are provided, then all attributes will be returned. If any of the requested attributes are not found, they will not appear in the result. [http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.AttributesToGet.html] scan operation supports attributes-to-get - *[https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Scan.html]* *Proposed solution* *1.* Scan operation(ScanCommand class) need to be enhanced to support attributes-to-get and additionally projection and filter expression. Scan operation has been enhanced to use the latest projection expression and filter expresion supported by aws . The new inputs would follow the pattern given as: { "projection-expression": "#id, #fname", "filter-expression": "#fname = :val", "select": "SPECIFIC_ATTRIBUTES", "expression-attribute-names": { "#id": "Id", "#fname": "FirstName" }, "expression-attribute-values": { ":val": { "S": "Kim" } }} 2. Enhance QueryComand class to accept global secondary indexes and attributes-to-get with empty values. When attributes-to-get is null or empty - it shall not throw a validation exception. {color:#007200}// Check if we have set an Index Name{color} {color:#000000} {color}{color:#0000ff}if{color}{color:#000000} (exchange.getIn().getHeader(Ddb2Constants.INDEX_NAME, String.{color}{color:#0000ff}class{color}{color:#000000}) != null) {{color} {color:#000000} query.indexName(exchange.getIn().getHeader(Ddb2Constants.INDEX_NAME, String.{color}{color:#0000ff}class{color}{color:#000000}));{color} {color:#000000} }{color} {color:#000000} {color}{color:#007200}//skip adding attribute-to-get from 'CamelAwsDdbAttributeNames' if the header is null or empty list.{color} {color:#000000} {color}{color:#0000ff}if{color}{color:#000000}(exchange.getIn().getHeader(Ddb2Constants.ATTRIBUTE_NAMES) != null &&{color} {color:#000000} !exchange.getIn().getHeader(Ddb2Constants.ATTRIBUTE_NAMES, Collection.{color}{color:#0000ff}class{color}{color:#000000}).isEmpty()){{color} {color:#000000} query.attributesToGet(determineAttributeNames());{color} {color:#000000} }{color} -- This message was sent by Atlassian Jira (v8.20.10#820010)