在DolphinDB中的二进制函数元编程

huangapple go评论65阅读模式
英文:

Metaprogramming for binary functions in DolphinDB

问题

当我处理涉及二进制函数的SELECT语句,例如 select func(a,b) from tb 时,无法使用 sqlCol 函数。 有人知道有什么可用的替代元编程技术来解决这种情况吗?

英文:

When I handled a SELECT statement involving a binary function, such as select func(a,b) from tb, the sqlCol function can not be used. Does anyone know any alternative metaprogramming techniques available to address this situation?

答案1

得分: 1

你可以使用 sqlColAlias,它接受一个元代码作为参数。要为二元函数生成元代码,你可以使用 makeUnifiedCallmakeCall 函数。

注意:当将列名用作参数时,你需要首先使用 sqlCol 将它们转换为列对象。

sql(select=sqlColAlias(makeUnifiedCall(funcByName("corr"), [sqlCol("a"), sqlCol("b")])), from="t")
英文:

You can use sqlColAlias, which accepts a metacode as an argument. To generate metacode for a binary function, you can use the makeUnifiedCall or makeCall functions.

Note: when using column names as arguments, you need to convert them to column objects using sqlCol first.

sql(select=sqlColAlias(makeUnifiedCall(funcByName("corr"), [sqlCol("a"), sqlCol("b")])), from="t")

huangapple
  • 本文由 发表于 2023年7月20日 10:04:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76726220.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定