我想远程查询DolphinDB中的数据库。该数据库是在服务器38.124.2.173上使用以下脚本在服务器上创建的,
tableSchema = table(100:0,`trainID`ts`tag01`tag02,`tag03,[INT,TIMESTAMP,FLOAT,FLOAT,FLOAT )
db1 = database("",VALUE,(today()-92)..(today()+60))
db2 = database("",RANGE,0..80*10+1)
db = database("dfs://zctestDB",COMPO,[db1,db2])
dfsTable = db.createPartitionedTable(tableSchema,"trainInfoTable",`ts`trainID)
我的查询代码如下,
def testParallelQuery( connVector,trainIDs,startTime, endTime ){
cols=`trainID`ts`tag01
whereConditions=[<trainID in trainIDs>,expr(sqlCol(`ts),between,startTime:endTime)]
script=sql(sqlCol(cols),"loadTable('dfs://zctestDB','trainInfoTable')",whereConditions)
return ploop(remoteRun{,script}, connVector)
}
host="38.124.2.173"
port=30599
connVector = loop(xdb, take(host, 10), port, "admin", "123456")
testParallelQuery( connVector,1..5,2019.06.14T00:00:00.000, 2019.06.14T01:00:00.000 )
运行后发生以下异常,
Error was raised when execution : Can't find the object with name loadTable('dfs://zctestDB','trainInfoTable')
我该如何解决这个问题?
答案 0 :(得分:0)
函数sql
帮助人们动态地构造一条sql语句。参数from
接受三种类型的数据:(1)表对象,(2)表示表或表联接的表达式,(3)与表对象关联的变量。
在特定情况下,请按如下所示将表达式传递给from
。
def runSQL(trainIDs, startTime, endTime){
cols = `trainID`ts`tag01
whereConditions = [<trainID in trainIDs>, expr(sqlCol(`ts), between, startTime:endTime)]
return sql(sqlCol(cols), loadTable('dfs://zctestDB','trainInfoTable'), whereConditions).eval()
}
def testParallelQuery( connVector,trainIDs,startTime, endTime ){
return ploop(remoteRun{,runSQL{trainIDs, startTime, endTime}}, connVector)
}
host="38.124.2.173"
port=30599
connVector = loop(xdb, take(host, 10), port, "admin", "123456")
testParallelQuery( connVector,1..5,2019.06.14T00:00:00.000, 2019.06.14T01:00:00.000 )