birt 4.6.0
我有以下查询,该查询在BIRT和DBVizualizer中均适用:
SELECT t1.keys as SUBSCRIBER_COMPLETE, t1.vals as previous_count, t2.vals as current_count from (
SELECT explode(map('Row Total', SUBSCRIBER_COMPLETE_TOTAL)) as (keys, vals)
FROM my_table
WHERE src_file_dt = '1222') t1,
(
SELECT explode(map('Row Total', SUBSCRIBER_COMPLETE_TOTAL)) as (keys, vals)
FROM my_table
WHERE src_file_dt = '5221') t2
where t1.keys = t2.keys
但是当我对其参数化时,会出现以下错误
[*org.apache.hive.service.cli.HiveSQLException:Error while compiling statement: FAILED: ParseException line 1:246 cannot recognize input near '?' ')' 't1' in expression specification:17:16
查询方式:
SELECT t1.keys as SUBSCRIBER_COMPLETE, t1.vals as previous_count, t2.vals as current_count from (
SELECT explode(map('Row Total', SUBSCRIBER_COMPLETE_TOTAL)) as (keys, vals)
FROM my_table
WHERE src_file_dt = ?) t1,
(
SELECT explode(map('Row Total', SUBSCRIBER_COMPLETE_TOTAL)) as (keys, vals)
FROM my_table
WHERE src_file_dt = ?) t2
where t1.keys = t2.keys
我什至可以单行尝试:
SELECT t1.keys as SUBSCRIBER_COMPLETE, t1.vals as previous_count, t2.vals as current_count from (SELECT explode(map('Row Total', SUBSCRIBER_COMPLETE_TOTAL)) as (keys, vals) FROM my_table WHERE src_file_dt = ?) t1, (SELECT explode(map('Row Total', SUBSCRIBER_COMPLETE_TOTAL)) as (keys, vals) FROM my_table WHERE src_file_dt = ?) t2 where t1.keys = t2.keys
答案 0 :(得分:0)
我从来没有能够使它工作。似乎是bug in Eclipse/BIRT
我能够通过替换数据集的beforeOpen脚本中的查询中的变量来解决该问题,例如
this.queryText = String(queryText).replace("'prev'", params["PREV_DATE"]);
this.queryText = String(queryText).replace("'curr'", params["CURR_DATE"]);