-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
toString for windowing elements corrected
lax equality test implemented included oracle test sqls included @ and # for identifiers
- Loading branch information
Showing
281 changed files
with
2,775 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/test/java/net/sf/jsqlparser/test/select/SpecialOracleTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (C) 2014 JSQLParser. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
* MA 02110-1301 USA | ||
*/ | ||
package net.sf.jsqlparser.test.select; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import net.sf.jsqlparser.JSQLParserException; | ||
import static net.sf.jsqlparser.test.TestUtils.*; | ||
import org.apache.commons.io.FileUtils; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Tries to parse and deparse all statments in net.sf.jsqlparser.test.oracle-tests. | ||
* @author toben | ||
*/ | ||
public class SpecialOracleTests { | ||
|
||
private static final File SQLS_DIR = new File("target/test-classes/net/sf/jsqlparser/test/oracle-tests"); | ||
private static final Logger LOG = Logger.getLogger(SpecialOracleTests.class.getName()); | ||
|
||
@Test | ||
public void testAllSqls() throws IOException { | ||
File[] sqlTestFiles = SQLS_DIR.listFiles(); | ||
|
||
for (File file : sqlTestFiles) { | ||
LOG.log(Level.INFO, "testing {0}", file.getName()); | ||
String sql = FileUtils.readFileToString(file); | ||
try { | ||
assertSqlCanBeParsedAndDeparsed(sql, true); | ||
|
||
LOG.info(" -> SUCCESS"); | ||
} catch (JSQLParserException ex) { | ||
LOG.log(Level.SEVERE, null, ex); | ||
} | ||
} | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
src/test/resources/net/sf/jsqlparser/test/oracle-tests/aggregate01.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
with | ||
codes2codelocales as | ||
( | ||
select t6.cdl_name as cod_name, t7.cdl_name as cod_cod_name, t14.cod_oid | ||
from servicedesk.itsm_codes t14 | ||
left outer join servicedesk.itsm_codes_locale t6 on (t6.cdl_cod_oid=t14.cod_oid) | ||
left outer join servicedesk.itsm_codes_locale t7 on (t7.cdl_cod_oid=t14.cod_cod_oid) | ||
) | ||
, incident as | ||
( | ||
select t1.*, | ||
c2cl1.cod_name as "closure code", c2cl1.cod_cod_name as "closure code parent", | ||
c2cl2.cod_name as "reason caused code", c2cl2.cod_cod_name as "reason caused code parent", | ||
t11.cdl_name "severity", t13.cdl_name "business impact", t16.cdl_name "priority", | ||
t2.rct_name "status", t12.rct_name "category", t99.rct_name "folder" | ||
from servicedesk.itsm_incidents t1 | ||
join servicedesk.itsm_codes_locale t11 on (t1.inc_sev_oid=t11.cdl_cod_oid) | ||
join servicedesk.itsm_codes_locale t13 on (t1.inc_imp_oid=t13.cdl_cod_oid) | ||
join servicedesk.itsm_codes_locale t16 on (t1.inc_pri_oid=t16.cdl_cod_oid) | ||
join servicedeskrepo.rep_codes_text t2 on (t1.inc_sta_oid=t2.rct_rcd_oid) | ||
join servicedeskrepo.rep_codes_text t12 on (t1.inc_cat_oid=t12.rct_rcd_oid) | ||
join servicedeskrepo.rep_codes_text t99 on (t1.inc_poo_oid=t99.rct_rcd_oid) | ||
left outer join codes2codelocales c2cl1 on (t1.inc_clo_oid=c2cl1.cod_oid) | ||
left outer join codes2codelocales c2cl2 on (t1.inc_cla_oid=c2cl2.cod_oid) | ||
where t1."reg_created" between sysdate-1 and sysdate | ||
) | ||
, workgrouphistory as | ||
( | ||
select i.inc_id | ||
, max(t101.hin_subject) keep (dense_rank first order by (t101.reg_created)) as "first" | ||
, max(t101.hin_subject) keep (dense_rank last order by (t101.reg_created)) as "last" | ||
from | ||
servicedesk.itsm_historylines_incident t101 | ||
join incident i on (t101.hin_inc_oid = i.inc_oid) | ||
-- from servicedesk.itsm_incidents i (t101.hin_inc_oid = i.inc_oid) | ||
where t101.hin_subject like 'to workgroup from%' | ||
-- and i."reg_created" between sysdate-1 and sysdate | ||
group by i.inc_id | ||
) | ||
select | ||
incident.inc_id "id" | ||
,incident."status" | ||
,incident.inc_description "description" | ||
,t4.wog_searchcode "workgroup" | ||
,t5.per_searchcode "person" | ||
,incident.inc_solution "solution" | ||
,incident."closure code" | ||
,incident."closure code parent" | ||
,incident."reason caused code" | ||
,incident."reason caused code parent" | ||
,t10.cit_searchcode "ci" | ||
,incident."severity" | ||
,incident."category" | ||
,incident."business impact" | ||
,incident."priority" | ||
,to_char(incident."reg_created", 'dd-mm-yy hh24:mi:ss') "registered" | ||
,to_char(incident."inc_deadline", 'dd-mm-yy hh24:mi:ss') "deadline" | ||
,to_char(incident."inc_actualfinish", 'dd-mm-yy hh24:mi:ss') "finish" | ||
,t3.icf_incshorttext3 "message group" | ||
,t3.icf_incshorttext4 "application" | ||
,t3.icf_incshorttext2 "msg id" | ||
,incident."folder" | ||
,workgrouphistory."first" "first wg" | ||
,workgrouphistory."last" "last wg" | ||
,t102.hin_subject "frirst pri" | ||
from incident | ||
join servicedesk.itsm_inc_custom_fields t3 on (incident.inc_oid=t3.icf_inc_oid) | ||
join servicedesk.itsm_workgroups t4 on (incident.inc_assign_workgroup=t4.wog_oid) | ||
join workgrouphistory on (incident.inc_id = workgrouphistory.inc_id) | ||
left outer join servicedesk.itsm_persons t5 on (incident.inc_assign_person_to=t5.per_oid) | ||
left outer join servicedesk.itsm_configuration_items t10 on (incident.inc_cit_oid=t10.cit_oid) | ||
left outer join servicedesk.itsm_historylines_incident t102 on (incident.inc_oid = t102.hin_inc_oid and t102.hin_subject like 'priority set to%') |
11 changes: 11 additions & 0 deletions
11
src/test/resources/net/sf/jsqlparser/test/oracle-tests/analytic_query02.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
select time_id, product | ||
, last_value(quantity ignore nulls) over (partition by product order by time_id) quantity | ||
, last_value(quantity respect nulls) over (partition by product order by time_id) quantity | ||
from ( select times.time_id, product, quantity | ||
from inventory partition by (product) | ||
right outer join times on (times.time_id = inventory.time_id) | ||
where times.time_id between to_date('01/04/01', 'dd/mm/yy') | ||
and to_date('06/04/01', 'dd/mm/yy')) | ||
order by 2,1 | ||
|
||
|
8 changes: 8 additions & 0 deletions
8
src/test/resources/net/sf/jsqlparser/test/oracle-tests/analytic_query03.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
select times.time_id, product, quantity from inventory | ||
partition by (product) | ||
right outer join times on (times.time_id = inventory.time_id) | ||
where times.time_id between to_date('01/04/01', 'dd/mm/yy') | ||
and to_date('06/04/01', 'dd/mm/yy') | ||
order by 2,1 | ||
|
||
|
5 changes: 5 additions & 0 deletions
5
src/test/resources/net/sf/jsqlparser/test/oracle-tests/analytic_query04.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
select deptno | ||
, ename | ||
, hiredate | ||
, listagg(ename, ',') within group (order by hiredate) over (partition by deptno) as employees | ||
from emp |
17 changes: 17 additions & 0 deletions
17
src/test/resources/net/sf/jsqlparser/test/oracle-tests/analytic_query05.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
select metric_id ,bsln_guid ,timegroup ,obs_value as obs_value | ||
, cume_dist () over (partition by metric_id, bsln_guid, timegroup order by obs_value ) as cume_dist | ||
, count(1) over (partition by metric_id, bsln_guid, timegroup ) as n | ||
, row_number () over (partition by metric_id, bsln_guid, timegroup order by obs_value) as rrank | ||
, percentile_disc(:b7 ) within group (order by obs_value asc) over (partition by metric_id, bsln_guid, timegroup) as mid_tail_value | ||
, max(obs_value) over (partition by metric_id, bsln_guid, timegroup ) as max_val | ||
, min(obs_value) over (partition by metric_id, bsln_guid, timegroup ) as min_val | ||
, avg(obs_value) over (partition by metric_id, bsln_guid, timegroup ) as avg_val | ||
, stddev(obs_value) over (partition by metric_id, bsln_guid, timegroup ) as sdev_val | ||
, percentile_cont(0.25) within group (order by obs_value asc) over (partition by metric_id, bsln_guid, timegroup) as pctile_25 | ||
, percentile_cont(0.5) within group (order by obs_value asc) over (partition by metric_id, bsln_guid, timegroup) as pctile_50 | ||
, percentile_cont(0.75) within group (order by obs_value asc) over (partition by metric_id, bsln_guid, timegroup) as pctile_75 | ||
, percentile_cont(0.90) within group (order by obs_value asc) over (partition by metric_id, bsln_guid, timegroup) as pctile_90 | ||
, percentile_cont(0.95) within group (order by obs_value asc) over (partition by metric_id, bsln_guid, timegroup) as pctile_95 | ||
, percentile_cont(0.99) within group (order by obs_value asc) over (partition by metric_id, bsln_guid, timegroup) as pctile_99 | ||
from timegrouped_rawdata d | ||
|
1 change: 1 addition & 0 deletions
1
src/test/resources/net/sf/jsqlparser/test/oracle-tests/analytic_query06.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
select trim(both ' ' from ' a ') from dual where trim(:a) is not null |
39 changes: 39 additions & 0 deletions
39
src/test/resources/net/sf/jsqlparser/test/oracle-tests/analytic_query07.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
with | ||
clus_tab as ( | ||
select id, | ||
a.attribute_name aname, | ||
a.conditional_operator op, | ||
nvl(a.attribute_str_value, | ||
round(decode(a.attribute_name, n.col, | ||
a.attribute_num_value * n.scale + n.shift, | ||
a.attribute_num_value),4)) val, | ||
a.attribute_support support, | ||
a.attribute_confidence confidence | ||
from table(dbms_data_mining.get_model_details_km('km_sh_clus_sample')) t, | ||
table(t.rule.antecedent) a, | ||
km_sh_sample_norm n | ||
where a.attribute_name = n.col (+) and a.attribute_confidence > 0.55 | ||
), | ||
clust as ( | ||
select id, | ||
cast(collect(cattr(aname, op, to_char(val), support, confidence)) as cattrs) cl_attrs | ||
from clus_tab | ||
group by id | ||
), | ||
custclus as ( | ||
select t.cust_id, s.cluster_id, s.probability | ||
from (select | ||
cust_id | ||
, cluster_set(km_sh_clus_sample, null, 0.2 using *) pset | ||
from km_sh_sample_apply_prepared | ||
where cust_id = 101362) t, | ||
table(t.pset) s | ||
) | ||
select a.probability prob, a.cluster_id cl_id, | ||
b.attr, b.op, b.val, b.supp, b.conf | ||
from custclus a, | ||
(select t.id, c.* | ||
from clust t, | ||
table(t.cl_attrs) c) b | ||
where a.cluster_id = b.id | ||
order by prob desc, cl_id asc, conf desc, attr asc, val asc |
4 changes: 4 additions & 0 deletions
4
src/test/resources/net/sf/jsqlparser/test/oracle-tests/analytic_query08.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
select manager_id, last_name, hire_date, | ||
count(*) over (partition by manager_id order by hire_date | ||
range numtodsinterval(100, 'day') preceding) as t_count | ||
from employees |
13 changes: 13 additions & 0 deletions
13
src/test/resources/net/sf/jsqlparser/test/oracle-tests/analytic_query09.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
select | ||
listagg(column_value, ',') within group (order by column_value) | ||
from | ||
table( | ||
cast( | ||
multiset( | ||
select 'one' from dual | ||
union all | ||
select 'two' from dual | ||
) as t_str | ||
) | ||
) | ||
|
12 changes: 12 additions & 0 deletions
12
src/test/resources/net/sf/jsqlparser/test/oracle-tests/analytic_query10.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
SELECT STALENESS, | ||
OSIZE, OBJ#, | ||
TYPE#, | ||
ROW_NUMBER() OVER (PARTITION BY BO# ORDER BY STALENESS, OSIZE, OBJ#), | ||
CASE WHEN ROW_NUMBER() OVER (PARTITION BY BO# ORDER BY STALENESS, OSIZE, OBJ#) = 1 THEN 64 ELSE 0 END + | ||
CASE WHEN ROW_NUMBER() OVER (PARTITION BY (SELECT TCP0.BO# FROM TABCOMPART$ TCP0 WHERE TCP0.OBJ#=ST0.BO#) ORDER BY STALENESS, OSIZE, OBJ#) = 1 THEN 32 | ||
ELSE 0 END AFLAGS, | ||
0 STATUS, | ||
:B5 SID, | ||
:B4 SERIAL#, PART#, BO#, LOC_STALE_PCT | ||
FROM | ||
A |
Oops, something went wrong.