可以用join(<-)函数:
def generateReport(tbl, colNames, colFormat): sql(sqlColAlias(each(makeCall{format},sqlCol(colNames),colFormat),colNames)<-sqlCol("city"), tbl).eval();
执行generateReport(t, ["id", "date","price","qty"], ["0", "MM/dd/yyyy", "0.00", "#,###"])结果:
id date price qty city
1 01/02/2018 70.86 518 E
2 01/03/2018 81.32 8,132 A
3 01/04/2018 88.08 9,599 C
4 01/05/2018 77.98 4,101 G
5 01/06/2018 16.44 9,191 F
6 01/07/2018 48.81 8,953 A
7 01/08/2018 36.65 459 E
8 01/09/2018 35.80 4,012 C
……