content: package com.alibaba.druid.bvt.sql.schemaStat;
  
  import com.alibaba.druid.sql.SQLUtils;
  import com.alibaba.druid.sql.ast.SQLStatement;
  import com.alibaba.druid.sql.parser.SQLParserUtils;
  import com.alibaba.druid.sql.parser.SQLStatementParser;
  import com.alibaba.druid.sql.repository.SchemaRepository;
  import com.alibaba.druid.sql.visitor.SchemaStatVisitor;
  import com.alibaba.druid.util.JdbcConstants;
  import junit.framework.TestCase;
  
  public class SchemaStatTest17 extends TestCase {
      public void test_schemaStat() throws Exception {
          SchemaRepository repository = new SchemaRepository(JdbcConstants.MYSQL);
  
          String sql = "SELECT * FROM t WHERE f1 -1 < 3;";
  
          SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(sql, JdbcConstants.MYSQL);
          SQLStatement stmt = parser.parseStatementList().get(0);
  
          SchemaStatVisitor statVisitor = SQLUtils.createSchemaStatVisitor(repository);
          stmt.accept(statVisitor);
  
          System.out.println("Tables : " + statVisitor.getTables());
          System.out.println(statVisitor.getColumns());
  //        System.out.println(statVisitor.getGroupByColumns()); // group by
          System.out.println("relationships : " + statVisitor.getRelationships()); // group by
          System.out.println(statVisitor.getConditions());
  
          assertEquals(2, statVisitor.getColumns().size());
          assertEquals(1, statVisitor.getConditions().size());
          assertEquals(0, statVisitor.getFunctions().size());
  
          assertTrue(statVisitor.containsTable("t"));
          assertTrue(statVisitor.containsColumn("t", "f1"));
          assertEquals("t.f1 < 4", statVisitor.getConditions().get(0).toString());
      }
  }
  