Skip to content

Commit

Permalink
Minor,fix gaussdb parse interval error.
Browse files Browse the repository at this point in the history
  • Loading branch information
woyumen4597 authored and wenshao committed Nov 6, 2024
1 parent d64c6bf commit 4467a00
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,15 @@ protected SQLExpr parseInterval() {
) {
return new SQLIdentifierExpr("INTERVAL");
}
SQLExpr value = expr();

if (value instanceof SQLCharExpr) {
String literal = ((SQLCharExpr) value).getText();
String[] split = literal.split(" ");
if (split.length == 2) {
return new SQLIntervalExpr(new SQLIntegerExpr(Integer.parseInt(split[0])), SQLIntervalUnit.of(split[1]));
} else {
intervalExpr.setValue(value);
return intervalExpr;
}
SQLExpr value = new SQLCharExpr(lexer.stringVal());
lexer.nextToken();
String literal = ((SQLCharExpr) value).getText();
String[] split = literal.split(" ");
if (split.length == 2) {
return new SQLIntervalExpr(new SQLIntegerExpr(Integer.parseInt(split[0])), SQLIntervalUnit.of(split[1]));
} else {
intervalExpr.setValue(value);
return intervalExpr;
}
return intervalExpr;
}
}
21 changes: 20 additions & 1 deletion core/src/test/resources/bvt/parser/gaussdb/3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,23 @@ SELECT INTERVAL '3 DAYS'
------------------------------------------------------------------------------------------------------------------------
SELECT INTERVAL '1 year 2 months 3 days 5 hours'
--------------------
SELECT INTERVAL '1 year 2 months 3 days 5 hours'
SELECT INTERVAL '1 year 2 months 3 days 5 hours'
------------------------------------------------------------------------------------------------------------------------
select vin,
city,
sum(dur_time)
from dws.dws_cnet_nev_vehicle_stop_location_poi_day_staytime_d
where dt between '${dt}'::TIMESTAMP - interval '1 month' and '${dt}'
group by vin, city
--------------------
SELECT vin, city, sum(dur_time)
FROM dws.dws_cnet_nev_vehicle_stop_location_poi_day_staytime_d
WHERE dt BETWEEN '${dt}'::TIMESTAMP - INTERVAL '1 MONTH' AND '${dt}'
GROUP BY vin, city
------------------------------------------------------------------------------------------------------------------------
select prod_category_l1_name,the_date_week from ads.mid_ota_order
group by 1,2,3,4,8,rollup(delivery_bigarea_name)
--------------------
SELECT prod_category_l1_name, the_date_week
FROM ads.mid_ota_order
GROUP BY 1, 2, 3, 4, 8, rollup(delivery_bigarea_name)

0 comments on commit 4467a00

Please sign in to comment.