content: package com.alibaba.druid.bvt.sql.hive;
  
  import com.alibaba.druid.sql.SQLUtils;
  import com.alibaba.druid.sql.ast.SQLStatement;
  import com.alibaba.druid.sql.visitor.SchemaStatVisitor;
  import com.alibaba.druid.util.JdbcConstants;
  import junit.framework.TestCase;
  
  import java.util.List;
  
  public class HiveSelectTest_4_array
          extends TestCase {
      public void test_select() throws Exception {
          String sql = "select religions['catholic'][0] from json_nested_test;";
          assertEquals("SELECT religions['catholic'][0]\n" +
                  "FROM json_nested_test;", SQLUtils.formatHive(sql));
          assertEquals("select religions['catholic'][0]\n" +
                  "from json_nested_test;", SQLUtils.formatHive(sql, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION));
  
          List<SQLStatement> statementList = SQLUtils.parseStatements(sql, JdbcConstants.HIVE);
          SQLStatement stmt = statementList.get(0);
  
          assertEquals(1, statementList.size());
  
          SchemaStatVisitor visitor = SQLUtils.createSchemaStatVisitor(JdbcConstants.HIVE);
          stmt.accept(visitor);
  
          System.out.println("Tables : " + visitor.getTables());
          System.out.println("fields : " + visitor.getColumns());
  //      System.out.println("coditions : " + visitor.getConditions());
  //      System.out.println("orderBy : " + visitor.getOrderByColumns());
  
          assertEquals(1, visitor.getTables().size());
          assertEquals(1, visitor.getColumns().size());
          assertEquals(0, visitor.getConditions().size());
  
          assertTrue(visitor.containsColumn("json_nested_test", "religions"));
  //        assertTrue(visitor.containsColumn("customers", "isxx"));
  //        assertTrue(visitor.containsColumn("customers", "*"));
      }
  }
  