DolphinDB:sqlCol和sqlColAlias之间的区别

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

DolphinDB: The difference between sqlCol and sqlColAlias

问题

以下是翻译好的部分:

sqlCol(code,ratios,`ret)

sqlColAlias(<ratios(code)>,`ret)

预期能够达到相同的结果。但后者引发了以下错误:

服务器响应:'::evaluate(sql((sqlCol("date"), sqlColAlias(< ratios(code) >, "ret")), table)) => 用法:ratios(X)。X 不能是字符串或符号类型。'

为什么会发生这种情况?这两个函数之间有什么区别?

英文:

Here is my script, where sqlCol and sqlColAlias are used respectively:

code=`000905
sql((sqlCol(`date),sqlCol(code,ratios, `ret)),table ).eval()
sql((sqlCol(`date),sqlColAlias(<ratios(code)>,`ret)),table).eval()

sqlCol(code,ratios,`ret)

and

sqlColAlias(<ratios(code)>,`ret)

are expected to achieve the same result. But the latter one raises the following error:

Server response: '::evaluate(sql((sqlCol("date"), sqlColAlias(< ratios(code) >, "ret")), table)) => Usage: ratios(X). X can't be string or symbol type.'

Why is that happening? What is the difference between these two functions?

答案1

得分: 1

sql((sqlCol(`date),sqlCol(code, ratios, `ret)),table ).eval()

在上述代码中,code 是代表表格中的列 00905 的列变量。因此,这个表达式计算了列 00905 的比率。

sql((sqlCol(`date),sqlColAlias(<ratios(code)>,`ret)),table).eval()

在上述代码中,<ratios(code)> 是一个元代码表达式。code 不再是用于查询列 00905 的变量,而是解析为一个新列,该列完全包含字符串 "code",无法作为 ratios() 的参数使用。

英文:
sql((sqlCol(`date),sqlCol(code,ratios, `ret)),table ).eval()

In sqlCol(code,ratios,`ret), code is a column variable representing the column 00905 in the table. Therefore, the expression calculates the ratios of the column 00905.

sql((sqlCol(`date),sqlColAlias(<ratios(code)>,`ret)),table).eval()

In sqlColAlias(<ratios(code)>,`ret), <ratios(code)> is a metacode expression. code, instead of being a variable used to query the column 00905, is parsed into a new column containing entirely the string "code", which cannot be used as the parameter of ratios().

huangapple
  • 本文由 发表于 2023年6月12日 14:01:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76453958.html
匿名

发表评论

匿名网友

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

确定