Git Product home page Git Product logo

Comments (3)

igorcoding avatar igorcoding commented on July 17, 2024

Hello. This is just how Tarantool underlying protocol works.
What you see in the CALL is that Tarantool wraps everything you return from a function into a tuple, so it would be possible to make a multi value return, like this:

function f()
    return 1, 2, 3
end

The results from function above will arrive to python as an array [1, 2, 3].
So essentially result_2 means "array of return results, containing 1 array, containing 2 tuples [20] and [42]"
The difference of return types (TarantoolTuple vs list) comes from the difference in representing tuples. When you perform a SELECT request asynctnt knows what space you are selecting from, so it wraps results to TarantoolTuple which can be used either as a list or as a dict (just like in Tarantool itself).
But when you use CALL asynctnt can make no assumptions about data nature and its structure, so it returns data as is.

So, in a few words, it is impossible to deduce anything from a CALL on a connector side.
What you see in Tarantool REPL is just an unpack() of everything returned from a function and it does not look like an array.

from asynctnt.

nodermann avatar nodermann commented on July 17, 2024

Ok, that makes sense, thank you. I added unpack() function:

function find(space, keys)
    local result = {}
    for i, key in pairs(keys) do
        result[i] = box.space[space]:select({key})[1]
    end
    return unpack(result)
end

Now all is well:

result_2 <Response sync=7 rowcount=2 data=[[20], [42]]>

from asynctnt.

igorcoding avatar igorcoding commented on July 17, 2024

Is everything clear, can I close the issue?

from asynctnt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.