5 kyu

Vector addition

Description
Loading description...
Databases
  • Please sign in or sign up to leave a comment.
  • MrGerlach Avatar

    I think it would be much better if instead of writing about SQL magic, it would simply inform users about the creation of the operator.

  • JRGGP Avatar

    I have a solutions that works using 'create function - unnest - ordinality - cardinality', but still I hece the same error: I do not what is happening....any suggestion? Thks

    --- Caused by: ---

    PG::UndefinedFunction:

    ERROR: operator does not exist: integer[] + integer[]

    LINE 1: SELECT id, a, b, c, a + b AS "a + b", (a + b) + c AS "(a + b...

    ^

    HINT: No operator matches the given name and argument types. You might need to add explicit type casts.

    /usr/local/bundle/gems/sequel-5.47.0/lib/sequel/adapters/postgres.rb:156:in `exec'

    No examples found.

  • Asad812 Avatar

    This comment has been hidden.

  • zolton Avatar

    This comment has been hidden.

  • zolton Avatar

    This comment has been hidden.

  • SamHall14 Avatar

    I'm rather new to this and I never have made a function let alone try to alter a binary operator. This is using the CREATE FUNCTION ultility within the language, yes? https://www.postgresql.org/docs/current/sql-createfunction.html

  • mr.zh6 Avatar

    I believe my solution is working correctly but I'm getting this kind of error (which actualy is not from my code):

    PG::UndefinedFunction:

    ERROR: operator does not exist: integer[] + integer[]

    LINE 1: SELECT id, a, b, c, a + b AS "a + b", (a + b) + c AS "(a + b...

    Could someone explain this to me, please?

    • FArekkusu Avatar

      do vector addition on int[] arrays (...) using the + operator

      Your solution is incomplete (and the error message comes from it not fulfilling the requirements).

      Question marked resolved by FArekkusu 3 years ago
    • mr.zh6 Avatar

      This comment has been hidden.

  • alex2880s Avatar

    Are you sure that checking works in an appropriate way? An error appears every time during the checking, even we have only 'SELECT * FROM arrays' statement.

    An error occurred while loading ./main.rb. Failure/Error: @db.log_connection_yield(sql, self, args){args ? async_exec(sql, args) : async_exec(sql)}

  • MobulaKuhlii Avatar

    it's approvable now, anyone feeling brave enough can do it

  • dfhwze Avatar

    I'm a bit confused about the structure. Your example show arrays "a" and "b", but the sample tests show 3 arrays. Should we add 2, 3 or a dynamic number of arrays together?

    • FArekkusu Avatar

      + is a binary operator, how are you going to add more than 2 arrays at once?

    • dfhwze Avatar

      with some kind of "fold" (+)

    • FArekkusu Avatar

      The tests simply try to evaluate a (a + b) + c expression, what "dynamic number of arrays" and "fold (+)" are you talking about? Are you asking for an explanation of how addition works, or something?

      I'm resolving this question because it makes zero sense whatsover.

      Question marked resolved by FArekkusu 4 years ago
    • dfhwze Avatar

      I read over the fact we are required to create an operator and thought we needed to make a query instead.