请问 sql 动态语句支持 context by 参数吗

我写了下面语句:

dt = sql(select=[sqlCol("code"),
	sqlColAlias(parseExpr(buy_level_1_sum),"buy_level_19_sum"),
	sqlColAlias(parseExpr(sell_level_1_sum),"sell_level_1_sum"),
	sqlColAlias(parseExpr("delta_t1(time)"),"t1"),
	sqlColAlias(parseExpr("delta_t2(time)"),"t2")],from=t,context by=sqlCol("code")).eval()

执行后提示:If one argument is passed as keyword argument, all subsequent arguments must also be passed as keyword arguments,改用contextBy和context_by也不行。


请先 登录 后评论

1 个回答

wale

有个groupFlag 参数:1表示group by,0表示context by,2表示pivot by。默认值为1。

dt = sql(select=[sqlCol("code"),
	sqlColAlias(parseExpr(buy_level_1_sum),"buy_level_19_sum"),
	sqlColAlias(parseExpr(sell_level_1_sum),"sell_level_1_sum"),
	sqlColAlias(parseExpr("delta_t1(time)"),"t1"),
	sqlColAlias(parseExpr("delta_t2(time)"),"t2")],from=t,groupBy=sqlCol("code"),groupFlag=0).eval()


请先 登录 后评论