Skip to content

Commit

Permalink
interver 支持数字
Browse files Browse the repository at this point in the history
  • Loading branch information
melin committed Sep 26, 2023
1 parent 3fbf02a commit 4013e91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/main/java/io/github/melin/sqlflow/parser/AstBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -1554,9 +1554,16 @@ public Node visitBooleanValue(SqlFlowParser.BooleanValueContext context) {

@Override
public Node visitInterval(SqlFlowParser.IntervalContext context) {
String value = null;
if (context.string() != null) {
value = ((StringLiteral) visit(context.string())).getValue();
} else {
value = context.INTEGER_VALUE().getText();
}

return new IntervalLiteral(
getLocation(context),
((StringLiteral) visit(context.string())).getValue(),
value,
Optional.ofNullable(context.sign)
.map(AstBuilder::getIntervalSign)
.orElse(IntervalLiteral.Sign.POSITIVE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class SparkSqlLineageTest extends AbstractSqlLineageTest {

@Test
public void testInsertInto() throws Exception {
String sql = "with sdfa as (select concat(a.COL1, '-', a.COL2), a.desc, substr(current_timestamp(),1,19) AS data_store_time " +
String sql = "with sdfa as (select concat(a.COL1, '-', a.COL2), a.desc," +
"substr(current_timestamp(),1,19) AS data_store_time, current_date - INTERVAL 10 MINUTE as dd " +
"from db1.test a where ds='201912') insert overwrite table db2.Demo select * from sdfa";
Statement statement = SQL_PARSER.createStatement(sql);

Expand Down

0 comments on commit 4013e91

Please sign in to comment.