/* * Copyright 1999-2011 Alibaba Group Holding Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.alipay.zdal.parser.druid.bvt.sql.oracle; import java.util.List; import com.alipay.zdal.parser.druid.sql.OracleTest; import com.alipay.zdal.parser.sql.ast.SQLStatement; import com.alipay.zdal.parser.sql.dialect.oracle.parser.OracleStatementParser; import com.alipay.zdal.parser.sql.dialect.oracle.visitor.OracleSchemaStatVisitor; /** * * @author xiaoqing.zhouxq * @version $Id: OracleSelectGroupingTest.java, v 0.1 2012-5-17 ����10:19:41 xiaoqing.zhouxq Exp $ */ public class OracleSelectGroupingTest extends OracleTest { public void test_select() throws Exception { String sql = "SELECT COUNT(*) FROM employees e, departments d WHERE d.department_id = e.department_id GROUP BY e.department_name, d.job_id;"; OracleStatementParser parser = new OracleStatementParser(sql); List<SQLStatement> statementList = parser.parseStatementList(); SQLStatement statemen = statementList.get(0); print(statementList); OracleSchemaStatVisitor visitor = new OracleSchemaStatVisitor(); statemen.accept(visitor); System.out.println("Tables : " + visitor.getTables()); System.out.println("fields : " + visitor.getColumns()); System.out.println("alias : " + visitor.getAliasMap()); System.out.println("conditions : " + visitor.getConditions()); System.out.println("orderBy : " + visitor.getOrderByColumns()); System.out.println("groupBy : " + visitor.getGroupByColumns()); System.out.println("variant : " + visitor.getVariants()); System.out.println("relationShip : " + visitor.getRelationships()); System.out.println("--------------------------------"); output(statementList); } }