use of com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser in project druid by alibaba.
the class OracleOuterTest method test_oracle.
public void test_oracle() throws Exception {
String sql = "SELECT employee_id, manager_id\n" + "FROM employees\n" + "WHERE employees.manager_id(+) = employees.employee_id;";
String expect = "SELECT employee_id, manager_id\n" + "FROM employees\n" + "WHERE employees.manager_id(+) = employees.employee_id;\n";
OracleStatementParser parser = new OracleStatementParser(sql);
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
String text = TestUtils.outputOracle(stmt);
Assert.assertEquals(expect, text);
System.out.println(text);
}
use of com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser in project druid by alibaba.
the class OraclePivotClauseTest method test_pivot.
public void test_pivot() throws Exception {
String sql = "SELECT *\n" + "FROM (SELECT EXTRACT(YEAR FROM order_date) year, order_mode, order_total FROM orders)\n" + "PIVOT (SUM(order_total) FOR order_mode IN ('direct' AS Store, 'online' AS Internet));\n";
String expected = "SELECT *\n" + "FROM (\n\tSELECT EXTRACT(YEAR FROM order_date) AS year, order_mode, order_total\n" + "\tFROM orders\n" + ")\n" + "PIVOT (SUM(order_total) FOR order_mode IN ('direct' AS Store, 'online' AS Internet));\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);
}
use of com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser in project druid by alibaba.
the class OraclePivotClauseTest method test_0.
public void test_0() throws Exception {
String sql = "SELECT *\n" + "FROM pivot_table\n" + "UNPIVOT (yearly_total FOR order_mode IN (store AS 'direct', internet AS 'online'))\n" + "ORDER BY year, order_mode;";
String expected = "SELECT *\n" + "FROM pivot_table\n" + "UNPIVOT (yearly_total FOR order_mode IN (store AS 'direct', internet AS 'online'))\n" + "ORDER BY year, order_mode;\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);
}
use of com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser in project druid by alibaba.
the class OraclePivotClauseTest method test_pivot_1.
public void test_pivot_1() throws Exception {
String sql = "SELECT *\n" + "FROM (SELECT EXTRACT(YEAR FROM order_date) as year, order_mode, order_total FROM orders)\n" + "PIVOT (SUM(order_total) FOR order_mode IN ('direct' AS Store, 'online' AS Internet));\n";
String expected = "SELECT *\n" + "FROM (\n\tSELECT EXTRACT(YEAR FROM order_date) AS year, order_mode, order_total\n" + "\tFROM orders\n" + ")\n" + "PIVOT (SUM(order_total) FOR order_mode IN ('direct' AS Store, 'online' AS Internet));\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);
}
use of com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser in project druid by alibaba.
the class OracleCreateIndexTest1 method test_0.
public void test_0() throws Exception {
//
String sql = "create index PFS_PACKAGE_SAMPLE_PID_IND on PFS_PACKAGE_SAMPLE(PACKAGE_ID) tablespace appindx1m";
OracleStatementParser parser = new OracleStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statemen = statementList.get(0);
print(statementList);
Assert.assertEquals(1, statementList.size());
OracleSchemaStatVisitor visitor = new OracleSchemaStatVisitor();
statemen.accept(visitor);
System.out.println("Tables : " + visitor.getTables());
System.out.println("fields : " + visitor.getColumns());
System.out.println("coditions : " + visitor.getConditions());
System.out.println("relationships : " + visitor.getRelationships());
System.out.println("orderBy : " + visitor.getOrderByColumns());
Assert.assertEquals(1, visitor.getTables().size());
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("PFS_PACKAGE_SAMPLE")));
Assert.assertEquals(1, visitor.getColumns().size());
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("pivot_table", "*")));
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("pivot_table", "YEAR")));
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("pivot_table", "order_mode")));
}
Aggregations