Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list_append does not accept FunctionOperand #2994

Open
vitaliysapounov opened this issue Jun 23, 2023 · 3 comments
Open

list_append does not accept FunctionOperand #2994

vitaliysapounov opened this issue Jun 23, 2023 · 3 comments
Labels
bug This issue is a bug. p2 This is a standard priority issue

Comments

@vitaliysapounov
Copy link

vitaliysapounov commented Jun 23, 2023

Describe the bug

We tried to append an element to a List attribute in DynamoDB by executing an update like (https://stackoverflow.com/a/35001736):

SET my_list2 = list_append(if_not_exists(my_list2, :empty_list), :my_value)

Note that if_not_exists() is needed, as if the attribute does not yet exist, simply list_append(my_list2, :my_value) produces an error "The provided expression refers to an attribute that does not exist in the item".

However, in ExpressionSpecBuilder.java the following method defined:

    public static <T> ListAppendFunction list_append(String path,
            List<? extends T> value) {
        return new ListAppendFunction(L(path), new ListLiteralOperand(new LinkedList<T>(
                value)));
    }

Note that the first operand requires a path (String), but in our case we need to pass FunctionOperand (that ExpressionSpecBuilder.if_not_exists() returns). Another method needs to be introduced with a signature like:

    public static <T> ListAppendFunction list_append(FunctionOperand expression, List<? extends T> value)

or even just

    public static <T> ListAppendFunction list_append(Operand expression, List<? extends T> value)

Expected Behavior

ExpressionSpecBuilder.list_append() accepts FunctionOperand (or just Operand) as the first argument

Current Behavior

ExpressionSpecBuilder.list_append() accepts String (attribute path) only as the first argument

Reproduction Steps

package com.awsbug;

import java.util.Collections;

import static com.amazonaws.services.dynamodbv2.xspec.ExpressionSpecBuilder.L;
import static com.amazonaws.services.dynamodbv2.xspec.ExpressionSpecBuilder.list_append;

public class AwsBug {

    public static void main(String[] args) {
        return L("myAttr").set(
                list_append(
                        L("myAttr").ifNotExists(Collections.emptyList()),
                        "someStringLiteral"
                )
        );
    }
}

The above class does not compile.

Possible Solution

No response

Additional Information/Context

No response

AWS Java SDK version used

1.12.221

JDK version used

openjdk version "11.0.16" 2022-07-19 LTS OpenJDK Runtime Environment Corretto-11.0.16.8.1 (build 11.0.16+8-LTS) OpenJDK 64-Bit Server VM Corretto-11.0.16.8.1 (build 11.0.16+8-LTS, mixed mode)

Operating System and version

buntu 22.04.2 LTS

@vitaliysapounov vitaliysapounov added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 23, 2023
@debora-ito
Copy link
Member

@vitaliysapounov makes sense. Thank you for reporting.

Just a heads-up, the focus of the team is in Java SDK 2.x features, so this has a low chance to be implemented in 1.x.
ExpressionSpecBuilder is not supported in Java SDK 2.x, we are tracking here - aws/aws-sdk-java-v2#2995.

@debora-ito debora-ito added p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Jul 24, 2023
@vitaliysapounov
Copy link
Author

@debora-ito Thanks for answering! If I provide a pull request, will it be of any help?

@debora-ito
Copy link
Member

A little, but not significantly, unfortunately.
Java SDK 1.x mainline is in our internal systems, so we'd need to replicate the changes of the PR internally, and do the code review and perform tests. This would have low priority if compared to other tasks we need to work on.

We appreciate your interest in writing the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

2 participants