[ https://issues.apache.org/jira/browse/CAMEL-22029?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17947886#comment-17947886 ]
Kumar Gaurav commented on CAMEL-22029: -------------------------------------- WE are using the camel-aws-ddb component with routeTemplates – > kamelets within springboot app. We are writing routes using route yaml dsl and invoking those kamelets from those actual routes. > aws dynamodb scan and 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 > Reporter: Kumar Gaurav > Assignee: Andrea Cosentino > Priority: Major > > {*}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. Please note - It has also not been upgraded to use > projection and filter expressions. > > 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 attributes-to-get > parameter. Moreover, It has also not been upgraded to use projection and > filter expressions. > > > {*}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 which > 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. > > > *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)