AND DATE_TIMEKEY<=(SELECT DATE_END_TIMEKEY FROM DIM.DIM_CALENDAR WHERE TIME_KEY='${time_key}') 改成if判断参数0,为空,否则传上面函数
${IF(LEN(time_key)=0," ","AND DATE_TIMEKEY<=(SELECT DATE_END_TIMEKEY FROM DIM.DIM_CALENDAR WHERE TIME_KEY='${time_key}'} ")}是错误语法
${IF(LEN(time_key)=0," ","AND DATE_TIMEKEY<=(SELECT DATE_END_TIMEKEY FROM DIM.DIM_CALENDAR WHERE TIME_KEY=('"+time_key+"' )")}
${if}里面传参要调整格式,参数的括号带不带无所谓.
具体参考:https://help.fanruan.com/finereport/doc-view-158.html
${IF(LEN(time_key)=0," ","AND DATE_TIMEKEY<=(SELECT DATE_END_TIMEKEY FROM DIM.DIM_CALENDAR WHERE TIME_KEY='"+time_key+"' )")}