如何通过节点js运行复杂的cassandra sql

我试图从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 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中performance不同。

例如,你不能做像JOIN或子查询之类的东西。 它确实允许你做像DISTINCT和SUM这样的聚集,但是在何时以及如何使用这些方法方面有限制(只允许在特定的键上)。 以下是查询聚合的文档的链接: https : //docs.datastax.com/en/cql/latest/cql/cql_using/useQueryStdAggregate.html 。

而且,Cassandra 3.0的聚合也是新的。 如果您使用的是2.x版本,则唯一的select是在客户端执行一些处理。