ranger-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shubham Chaurasia <shubh.chaura...@gmail.com>
Subject Database metadata scenario in Hive plugin
Date Fri, 04 Jan 2019 11:03:43 GMT
Hi All,

I am encountering a strange scenario when trying to retrieve table names
using jdbc java.sql.Connection.getMetaData().getTables().

Ranger Policy
------------------------------------
Database: ranger_hive_test
Table: *
Hive Column: *
Allow Conditions: All permissions to the user.
------------------------------------

1) Now when I execute the below method:

  private static void testWithConnMetaData() throws SQLException {

System.out.println("---------------------------testWithConnMetaData-----------------------------");
    try (Connection con = DriverManager.getConnection(url, user, "")) {

      ResultSet res = con.getMetaData().getTables(null, "ranger_hive_test",
"t1", null);
      while (res.next()) {
        System.out.println(res.getString("TABLE_NAME"));
      }
    }

System.out.println("---------------------------testWithConnMetaData-----------------------------");
  }


I get empty resultset.

2) To verify policy and table existence when I execute the same using show
tables query, it gives me right results(table names in ranger_hive_test).
  private static void testWithQuery() throws SQLException {

System.out.println("---------------------------testWithQuery-----------------------------");
    try (Connection con = DriverManager.getConnection(url, user, "")) {
      Statement stmt = con.createStatement();

      String sql = "show tables in ranger_hive_test";
      ResultSet res = stmt.executeQuery(sql);
      while (res.next()) {
        System.out.println(res.getString("tab_name"));
      }
    }

System.out.println("---------------------------testWithQuery-----------------------------");
  }


Is there something I am missing so that I am not getting any results in
method 1 ? Anything else I need to add to policy?

Also surprisingly, when I add "*" to Database field in policy, I start
getting results in method 1.

Thanks,
Shubham

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message