mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
sample clause
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@982 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -541,7 +541,7 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
}
|
||||
|
||||
if (x.getSampleClause() != null) {
|
||||
print(" ");
|
||||
println();
|
||||
x.getSampleClause().accept(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.alibaba.druid.bvt.sql.oracle;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;
|
||||
import com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser;
|
||||
import com.alibaba.druid.sql.test.TestUtils;
|
||||
|
||||
public class OracleSampleClauseTest extends TestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
String sql = "SELECT COUNT(*) * 10 FROM orders SAMPLE (10);";
|
||||
|
||||
String expected = "SELECT COUNT(*) * 10\n" + "FROM orders\n" + "SAMPLE (10);\n";
|
||||
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals(expected, text);
|
||||
|
||||
System.out.println(text);
|
||||
}
|
||||
|
||||
public void test_1() throws Exception {
|
||||
String sql = "SELECT COUNT(*) * 10 FROM orders SAMPLE (10) SEED (1);";
|
||||
|
||||
String expected = "SELECT COUNT(*) * 10\n" + "FROM orders\n" + "SAMPLE (10) SEED (1);\n";
|
||||
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals(expected, text);
|
||||
|
||||
System.out.println(text);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user