Skip to content

Commit 1d37eb0

Browse files
feat: System.getProperty("SPLIT_NAMES_ON_DELIMITER") for allowing . dots in Table Names
- fixes #2179 Signed-off-by: Andreas Reichel <[email protected]>
1 parent e30f30d commit 1d37eb0

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/main/java/net/sf/jsqlparser/schema/Table.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ public class Table extends ASTNodeAccessImpl implements FromItem, MultiPartName
5858

5959
public Table() {}
6060

61+
/**
62+
* Instantiates a new Table.
63+
*
64+
* Sets the table name, splitting it into parts (catalog, schema, name) on `.` dots when quoted
65+
* unless the system property `SPLIT_NAMES_ON_DELIMITER` points to `FALSE`
66+
*
67+
* @param name the table name, optionally quoted
68+
*/
6169
public Table(String name) {
6270
setName(name);
6371
}
@@ -170,10 +178,22 @@ public String getName() {
170178
}
171179

172180

181+
/**
182+
* Sets the table name, splitting it into parts (catalog, schema, name) on `.` dots when quoted
183+
* unless the system property `SPLIT_NAMES_ON_DELIMITER` points to `FALSE`
184+
*
185+
* @param name the table name, optionally quoted
186+
*/
173187
public void setName(String name) {
174188
// BigQuery seems to allow things like: `catalogName.schemaName.tableName` in only one pair
175189
// of quotes
176-
if (MultiPartName.isQuoted(name) && name.contains(".")) {
190+
// however, some people believe that Dots in Names are a good idea, so provide a switch-off
191+
boolean splitNamesOnDelimiter = System.getProperty("SPLIT_NAMES_ON_DELIMITER") == null ||
192+
!List
193+
.of("0", "N", "n", "FALSE", "false", "OFF", "off")
194+
.contains(System.getProperty("SPLIT_NAMES_ON_DELIMITER"));
195+
196+
if (MultiPartName.isQuoted(name) && name.contains(".") && splitNamesOnDelimiter) {
177197
partItems.clear();
178198
for (String unquotedIdentifier : MultiPartName.unquote(name).split("\\.")) {
179199
partItems.add("\"" + unquotedIdentifier + "\"");

src/test/resources/net/sf/jsqlparser/statement/select/oracle-tests/query_factoring07.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,4 @@ select
8787
)
8888

8989
--@FAILURE: Encountered unexpected token: "by" "BY" recorded first on Aug 3, 2021, 7:20:08 AM
90-
--@SUCCESSFULLY_PARSED_AND_DEPARSED first on Nov 14, 2022, 11:44:23 AM
91-
--@FAILURE: (select bsln_statistics_t(bsln_guid,metric_id,:b11,:b10,timegroup,sample_count,average,minimum,maximum,sdev,pctile_25,pctile_50,pctile_75,pctile_90,pctile_95,pctile_99,est_sample_count,est_slope,est_intercept,case when est_slope=0 then 0 else greatest(0,nvl(100-(25*power((1-est_mu1/est_slope),2)*(est_sample_count-1)),0))end,ln(1000)*est_slope+est_intercept,ln(10000)*est_slope+est_intercept)from(select metric_id,bsln_guid,timegroup,est_mu as est_slope,est_mu*ln(alpha)+x_m as est_intercept,to_number(null)as est_fit_quality,case when count_below_x_j>0 then(sum_below_x_j+(n-m+1)*(x_j-x_m))/count_below_x_j-x_j else to_number(null)end as est_mu1,est_sample_count,n as sample_count,average,minimum,maximum,sdev,pctile_25,pctile_50,pctile_75,pctile_90,pctile_95,pctile_99 from(select metric_id,bsln_guid,timegroup,max(n)as n,count(rrank)as est_sample_count,case when count(rrank)>3 then(sum(obs_value)+(max(n)-max(rrank))*max(obs_value)-(max(n)-min(rrank)+1)*min(obs_value))/(count(rrank)-1)else to_number(null)end as est_mu,(max(n)-min(rrank)+1)/(max(n)+1)as alpha,min(obs_value)as x_m,max(obs_value)as x_l,max(rrank)as l,min(rrank)as m,max(mid_tail_value)as x_j,sum(case when obs_value<mid_tail_value then obs_value else 0 end)as sum_below_x_j,sum(case when cume_dist<:b7 then 1 else 0 end)as count_below_x_j,max(max_val)as maximum,max(min_val)as minimum,max(avg_val)as average,max(sdev_val)as sdev,max(pctile_25)as pctile_25,max(pctile_50)as pctile_50,max(pctile_75)as pctile_75,max(pctile_90)as pctile_90,max(pctile_95)as pctile_95,max(pctile_99)as pctile_99 from(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)x where x.cume_dist>=:b9 and x.cume_dist<=:b8 group by metric_id,bsln_guid,timegroup))) recorded first on 12 Jan 2025, 15:47:43
90+
--@SUCCESSFULLY_PARSED_AND_DEPARSED first on Nov 14, 2022, 11:44:23 AM

0 commit comments

Comments
 (0)