Node.js 如何通过node js运行cassandra的复杂sql
我正在尝试从node.js运行复杂的cassandra sql,并使用cassandra express包,下面是查询:Node.js 如何通过node js运行cassandra的复杂sql,node.js,express,cassandra,cql,Node.js,Express,Cassandra,Cql,我正在尝试从node.js运行复杂的cassandra sql,并使用cassandra express包,下面是查询: client.execute("select distinct c.objekt PSP, b.bestellung purchase_order, b.details, b.bestellnettowert Budget, c.Interim_Amounts, c.belegdatum, b.cost_centre
client.execute("select distinct c.objekt PSP, b.bestellung purchase_order, b.details, b.bestellnettowert Budget, c.Interim_Amounts, c.belegdatum, b.cost_centre
from
(select objekt, sum("Wert/KWahr") Interim_Amounts, belegdatum, bestellung from bdr.cj74 where year(belegdatum) = '2016' group by objekt, belegdatum, bestellung) c,
(select bestellung, "Lieferant/Lieferwerk" details, bestellnettowert, belegdatum, "PSP-Elm", "Kostenst." cost_centre from bdr.opexcapex where year(opexcapex.belegdatum) = '2016') b
where b."PSP-Elm" = c.objekt
and year(c.belegdatum) = year(b.belegdatum)
and c.bestellung = b.bestellung", [],
function(err, result) {
如果我运行简单的select语句,它会工作,任何帮助都会很好 简单地说,你不能。Cassandra支持CQL,而不是SQL。CQL的语法与SQL相似,但许多SQL关键字在CQL中的行为不同 例如,不能执行连接或子查询之类的操作。它确实允许您执行DISTINCT和SUM等聚合操作,但对使用这些方法的时间和方式有限制(仅允许在某些键上使用)。以下是有关使用聚合进行查询的文档的链接:
此外,从Cassandra 3.0开始,聚合是新的。如果您运行的是2.x版本,那么您唯一的选择就是在客户端进行一些处理。简单地说,您不能。Cassandra支持CQL,而不是SQL。CQL的语法与SQL相似,但许多SQL关键字在CQL中的行为不同 例如,不能执行连接或子查询之类的操作。它确实允许您执行DISTINCT和SUM等聚合操作,但对使用这些方法的时间和方式有限制(仅允许在某些键上使用)。以下是有关使用聚合进行查询的文档的链接: 此外,从Cassandra 3.0开始,聚合是新的。如果您运行的是2.x版本,那么您唯一的选择就是在客户端进行一些处理