From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id DE9166F852; Sun, 14 Nov 2021 19:24:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DE9166F852 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1636907064; bh=rJT+Utp9QwKAqnbrRL0OzWEWGmqHna6esKLXF0XCiG8=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Ie5KKiExRPPS+r0NqxysNgdWFH9Dje6SGRhtSfUzobGAgXHdWeNF0yrODqoKj59Ld ZuDmDEg/j4axQ2e6N4lO9sXg5GINfMg580YdIvR/U8i7dx+GZntuwwRJOZebQqbDIn NApIJa/55TeyDdmsQZ578hkeuUp1DzWk+UeJji6Q= Received: from smtp42.i.mail.ru (smtp42.i.mail.ru [94.100.177.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id F07BD6F852 for ; Sun, 14 Nov 2021 19:24:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F07BD6F852 Received: by smtp42.i.mail.ru with esmtpa (envelope-from ) id 1mmIIo-0001bQ-A8; Sun, 14 Nov 2021 19:24:22 +0300 Message-ID: Date: Sun, 14 Nov 2021 17:24:21 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Content-Language: en-US To: imeevma@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: <2febbd43dc012c13ccf2de0996b8b1e8bff9da54.1636630534.git.imeevma@gmail.com> In-Reply-To: <2febbd43dc012c13ccf2de0996b8b1e8bff9da54.1636630534.git.imeevma@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9731B3922EC063979CAB00300CDA98DC51CCA794E1CC6B18A00894C459B0CD1B995F7D7F371B266CA4CED8A61B918B08EDA6A3B310BF9EFEFDF792DC1A657B3D2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE712EB008F780777E9EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637CF20B9B7F5DD35A68638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D89112C661FB457D1BE7846CE6BD26CB46117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC3A703B70628EAD7BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18F04B652EEC242312D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE4B6963042765DA4B1AB2475877E8919AD8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE3568FCE88E0C8489DAD7EC71F1DB88427C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637BBEA499411984DA1EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A5981ED0303997C204626DDBEC00DD4EFF8FB5DFCF771778CDD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7536C62C4FBC402878410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34A5BF8FA0BD61F9945F0B4041518DE5DBD1C969EF5BFF7788DA3770CD9D39A55081F78774A72683851D7E09C32AA3244CF541DDCCB52A19177E7DEF4FA7DFAADC3C6EB905E3A8056B729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojjLiSo6osCe7LzgW2/g6DkA== X-Mailru-Sender: 1F3202E75A95DDEFFDAA31DDF78A2BDFA434F7D6D4C1C3DA1CE996C6B200B9EC90719D9526D31DD0841FB911095AA09146E8006E22572C39C920B61C43410E8717BDA556287159EE9437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 1/2] sql: introduce field type MAP X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks for the patch! See 5 comments below. On 11.11.2021 12:37, imeevma@tarantool.org wrote: > This patch introduces MAP to SQL. After this patch, all SQL operations > and built-in functions should work correctly with MAP values. However, > there is currently no way to create MAP values using only SQL tools. > > Part of #4763 > > @TarantoolBot document > Title: Field type MAP in SQL > > Properties of type MAP in SQL: > 1) a value ofttype MAP can be implicitly and explicitly cast only to > ANY; 1. ofttype -> of type. > 2) only a value of type ANY with primitive type MAP can be explicitly > cast to MAP; > 3) a value of any other type cannot be implicitly cast to MAP; > 4) a value of type MAP cannot participate in arithmetic, bitwise, > comparison, and concationation operations. 2. concationation -> concatenation. 3. You need to add a changelog file. For the arrays patch too. > @@ -3258,6 +3268,19 @@ port_vdbemem_dump_lua(struct port *base, struct lua_State *L, bool is_flat) > luaL_setarrayhint(L, -1); > return; > } > + case MEM_TYPE_MAP: { > + const char *data = mem->z; > + uint32_t size = mp_decode_map(&data); > + lua_createtable(L, 0, size); > + for (uint32_t i = 0; i < size; i++) { > + luamp_decode(L, luaL_msgpack_default, &data); > + luamp_decode(L, luaL_msgpack_default, &data); > + lua_settable(L, -3); > + } > + if (luaL_msgpack_default->decode_save_metatables) > + luaL_setmaphint(L, -1); 4. The same as for arrays. For both of them you can call luamp_decode on the root. > diff --git a/test/sql-tap/map.test.lua b/test/sql-tap/map.test.lua > new file mode 100755 > index 000000000..2be82db61 > --- /dev/null > +++ b/test/sql-tap/map.test.lua > @@ -0,0 +1,987 @@ > +#!/usr/bin/env tarantool > +local test = require("sqltester") > +test:plan(110) > + > +box.schema.func.create('M1', { > + language = 'Lua', > + body = 'function(a, b) return {[tostring(a)] = b} end', > + returns = 'map', > + param_list = {'any', 'any'}, > + exports = {'LUA', 'SQL'} > +}); > + > +box.schema.func.create('M2', { > + language = 'Lua', > + body = 'function(a, b, c, d) return '.. > + '{[tostring(a)] = b, [tostring(c)] = d} end', > + returns = 'map', > + param_list = {'any', 'any', 'any', 'any'}, > + exports = {'LUA', 'SQL'} > +}); > + > +box.schema.func.create('M3', { > + language = 'Lua', > + body = 'function(a, b, c, d, e, f) return '.. > + '{[tostring(a)] = b, [tostring(c)] = d, [tostring(e)] = f} end', 5. Why do you need the tostrings? Keys are free to have any type in MessagePack. In Lua too. Can you add tests for non-string keys? > + returns = 'map', > + param_list = {'any', 'any', 'any', 'any', 'any', 'any'}, > + exports = {'LUA', 'SQL'} > +});