-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improved sql parser bigquery support
- Loading branch information
Showing
5 changed files
with
40 additions
and
1 deletion.
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
30 changes: 30 additions & 0 deletions
30
core/src/test/java/com/alibaba/druid/bvt/sql/bigquery/AggregateTest.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,30 @@ | ||
package com.alibaba.druid.bvt.sql.bigquery; | ||
|
||
import com.alibaba.druid.DbType; | ||
import com.alibaba.druid.sql.SQLUtils; | ||
import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr; | ||
import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock; | ||
import com.alibaba.druid.sql.ast.statement.SQLSelectStatement; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertSame; | ||
|
||
public class AggregateTest { | ||
@Test | ||
public void test_agg() { | ||
String sql = "SELECT lag(date(d,'Asia/Jakarta')) over(partition by id order by n) FROM t1"; | ||
SQLSelectStatement stmt = (SQLSelectStatement) SQLUtils.parseSingleStatement(sql, DbType.bigquery); | ||
SQLSelectQueryBlock queryBlock = stmt.getSelect().getQueryBlock(); | ||
SQLAggregateExpr expr = (SQLAggregateExpr) queryBlock.getSelectList().get(0).getExpr(); | ||
assertSame(expr, expr.getArgument(0).getParent()); | ||
} | ||
|
||
@Test | ||
public void test_agg_1() { | ||
String sql = "SELECT xx(date(d,'Asia/Jakarta')) over(partition by id order by n) FROM t1"; | ||
SQLSelectStatement stmt = (SQLSelectStatement) SQLUtils.parseSingleStatement(sql, DbType.bigquery); | ||
SQLSelectQueryBlock queryBlock = stmt.getSelect().getQueryBlock(); | ||
SQLAggregateExpr expr = (SQLAggregateExpr) queryBlock.getSelectList().get(0).getExpr(); | ||
assertSame(expr, expr.getArgument(0).getParent()); | ||
} | ||
} |