sample clause

git-svn-id: http://code.alibabatech.com/svn/druid/trunk@982 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-10-15 10:18:44 +00:00
parent 10ad8df014
commit 9ba1788752
2 changed files with 43 additions and 1 deletions
@@ -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);
}
}