Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使sqrt和cos在tarantool SQL中可用?_Sql_Lua_Tarantool - Fatal编程技术网

如何使sqrt和cos在tarantool SQL中可用?

如何使sqrt和cos在tarantool SQL中可用?,sql,lua,tarantool,Sql,Lua,Tarantool,我尝试使用公式来估计距离,但当我尝试在tarantool sql中执行它时 box.execute [[SELECT "weight" + sqrt( cos("lat" - 12.31252) * ...]] 它表明: function SQRT() is not available in SQL Function 'COS' does not exist 如何使它们可用?这些在tarantool SQL开箱即用中尚不可用,但您可以使用box.sch

我尝试使用公式来估计距离,但当我尝试在tarantool sql中执行它时

box.execute [[SELECT "weight" + sqrt( cos("lat" - 12.31252) * ...]]
它表明:

function SQRT() is not available in SQL
Function 'COS' does not exist

如何使它们可用?

这些在tarantool SQL开箱即用中尚不可用,但您可以使用
box.schema.func.create
从SQL调用任意lua代码。以下是您需要做的:

box.schema.func.create(
  'COS', {
    returns="number", 
    body="function (num) return math.cos(num) end", 
    is_sandboxed=false,
    param_list={"number"}, 
    exports = {'LUA', 'SQL'}
  })
那么就这样称呼它:

box.execute("SELECT cos(123)")
要了解更多信息,请参阅