sqllineage icon indicating copy to clipboard operation
sqllineage copied to clipboard

with as clause does not parse properly

Open Dkbei opened this issue 2 years ago • 1 comments

hello,I also had the problem that the with clause could not be parsed, the script is as follows:

with temp_traffic_apicost as ( select to_date(create_time) as stat_dt, udfs.get_json_object(udfs.get_json_object(result, '$.data'),'$.queryStatus') as return_code, count(1) as api_times from etc_member.etc_traffic_query_log WHERE type in (1001, 1002) and udfs.get_json_object(udfs.get_json_object(result, '$.data'),'$.queryStatus') in ('0', '1', '2', '3', '4' ,'11', '12') and to_date(create_time) between $start_dt$ AND $end_dt$ GROUP BY stat_dt, return_code ), temp_increase_cars as ( select stat_dt, count(plate_no) as newmatch_cars, count(case when traffic_auth_status = 1 then plate_no end) as newbind_cars from ( select to_date(created_at) as stat_dt, plate_no, traffic_auth_status from etc.increase_cars where to_date(created_at) between $start_dt$ AND $end_dt$ and source = 1 ) t group by stat_dt ), temp_paid_orders as ( select to_date(pay_time) as stat_dt, count(distinct order_no) as paid_order_cnt from etc_member.etc_traffic_order a where delete_flag = 0 and to_date(pay_time) between $start_dt$ AND $end_dt$ group by stat_dt ), temp_dt as ( select stat_dt from ( select stat_dt from temp_traffic_apicost union all select stat_dt from temp_increase_cars union all select stat_dt from temp_paid_orders ) t group by stat_dt ), temp_datas as ( select t0.stat_dt, nvl(t1.allapi_times,0) as allapi_times, nvl(t1.queryapi_times,0) as queryapi_times, nvl(t2.newmatch_cars,0) as newmatch_cars, nvl(t2.newbind_cars,0) as newbind_cars, nvl(t3.paid_order_cnt,0) as paid_order_cnt from temp_dt t0 left join ( select stat_dt, sum(api_times) as allapi_times, sum(case when return_code = '1' then api_times else 0 end) as queryapi_times from temp_traffic_apicost group by stat_dt ) t1 on t0.stat_dt = t1.stat_dt left join temp_increase_cars t2 on t0.stat_dt = t2.stat_dt left join temp_paid_orders t3 on t0.stat_dt = t3.stat_dt ) select '汇总' as stat_dt, sum(allapi_times) as allapi_times, sum(queryapi_times) as queryapi_times, sum(newmatch_cars) as newmatch_cars, sum(newbind_cars) as newbind_cars, sum(paid_order_cnt) as paid_order_cnt from temp_datas union all select * from temp_datas order by 1 ;

Expected result: Statements(#): 1 Source Tables: .temp_increase_cars .temp_paid_orders etc.increase_cars etc_member.etc_traffic_order etc_member.etc_traffic_query_log Target Tables:

Actual results: Statements(#): 1 Source Tables: .temp_increase_cars .temp_paid_orders etc_member.etc_traffic_query_log Target Tables:

please help me.

Dkbei avatar Jul 14 '22 09:07 Dkbei

Update: I misunderstood this issue root cause previously. Let me check and get back to you.

reata avatar Jul 20 '22 13:07 reata

I checked the sql with v1.3.4, v1.3.5 and master. And this should be fixed by now. The output is as expected:

Statements(#): 1
Source Tables:
    etc.increase_cars
    etc_member.etc_traffic_order
    etc_member.etc_traffic_query_log
Target Tables:
    

reata avatar Aug 27 '22 05:08 reata