如何使sqrt和cos在tarantool SQL中可用?
我尝试使用公式来估计距离,但当我尝试在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
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)")
要了解更多信息,请参阅