[ 
https://issues.apache.org/jira/browse/HIVE-14687?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rahul Dhote updated HIVE-14687:
-------------------------------
    Description: 
During retrieving the privileges associated with table using Hive metastore 
api, it retrieves all other properties associated with table and gives null for 
privileges set 
.[https://hive.apache.org/javadocs/r1.2.1/api/org/apache/hadoop/hive/metastore/api/Table.html]

Configuration Applied:

Enable the SQL Authorization inside the Hive Server and user like hive,rootcare 
added inside admin role through hive configuration.

Problem:

Unable to retrieve the privileges for table using getPrivileges() method after 
connecting through HiveMetastoreClient api. getPrivileges methods return null 
whereas other properties of table are retrieved. 


Analysis:

I created the table using Hive user after connecting to HiveServer2 usingJDBC. 
By Default, after creating the table the default
privileges are assigned to the current user. It show all the privileges to 
table from hive prompt using sql.

Tried to explore the API, found that Table class is generated by thrift and 
consist of thrift code. I found that privileges field inside the Table class is 
made optional. Also, found that, the privileges are stored inside the table 
TBL_PRIVS inside metastore database.

Is there any specific configuration to be made to retrieve optional field ?

Options Tried:

1. Tried to print the isSetPrivilege() property, but it returns null.
2. Tried to add user in admin role which is connecting to hive metastore. Still 
it gives the getPrivileges() as null.

Sample Table Object Output:

Table(tableName:sr4, dbName:hadoop_schema, owner:hive,
createTime:1472192882, lastAccessTime:0, retention:0,
sd:StorageDescriptor(cols:[FieldSchema(name:id, type:int, comment:null),
FieldSchema(name:status, type:varchar(20), comment:null)], location:hdfs://
loco1.fyre.com:8020/apps/hive/warehouse/hadoop_schema.db/sr4,
inputFormat:org.apache.hadoop.mapred.TextInputFormat,
outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat,
compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null,
serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe,
parameters:{serialization.format=1}), bucketCols:[], sortCols:[],
parameters:{}, skewedInfo:SkewedInfo(skewedColNames:[], skewedColValues:[],
skewedColValueLocationMaps:{}), storedAsSubDirectories:false),
partitionKeys:[], parameters:{totalSize=17, sql.table.io.doAs=false,
numRows=-1, rawDataSize=-1, COLUMN_STATS_ACCURATE=false, numFiles=2,
transient_lastDdlTime=1472192963}, viewOriginalText:null,
viewExpandedText:null, tableType:MANAGED_TABLE)





  was:
Hi Team,

Trying to retrieve the privileges associated with table using Hive
metastore api. But after connecting hive metastore using api, it retrieves all 
other properties associated with table and gives null for privileges.

Configuration Applied:

Enable the SQL Authorization inside the Hive Server and user like hive,rootcare 
added inside admin role through hive configuration.
Problem:

Unable to retrieve the privileges for table using getPrivileges() method
after connecting through HiveMetastoreClient api. getPrivileges
methods return null whereas other properties of table are retrieved. 
[https://hive.apache.org/javadocs/r1.2.1/api/org/apache/hado
op/hive/metastore/api/Table.html]

Analysis:

I created the table using Hive user after connecting to HiveServer2 using
JDBC. By Default, after creating the table the default
privileges are assigned to the current user. It show all the privileges
from hive prompt.


Tried to explore the API, found that Table class is generated by thrift and
consist of thrift code. I found that privileges field inside the
Table class is made optional. Also, found that, the privileges are stored
inside the table TBL_PRIVS inside metastore database.
Is there any specific configuration to be made to retrieve optional field ?

Options Tried:

1. Tried to print the isSetPrivilege() property, but it returns null.
2. Tried to add user in admin role which is connecting to hive metastore.
Still it gives the getPrivileges() as null.


Sample Table Object Output:

Table(tableName:sr4, dbName:hadoop_schema, owner:hive,
createTime:1472192882, lastAccessTime:0, retention:0,
sd:StorageDescriptor(cols:[FieldSchema(name:id, type:int, comment:null),
FieldSchema(name:status, type:varchar(20), comment:null)], location:hdfs://
loco1.fyre.com:8020/apps/hive/warehouse/hadoop_schema.db/sr4,
inputFormat:org.apache.hadoop.mapred.TextInputFormat,
outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat,
compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null,
serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe,
parameters:{serialization.format=1}), bucketCols:[], sortCols:[],
parameters:{}, skewedInfo:SkewedInfo(skewedColNames:[], skewedColValues:[],
skewedColValueLocationMaps:{}), storedAsSubDirectories:false),
partitionKeys:[], parameters:{totalSize=17, sql.table.io.doAs=false,
numRows=-1, rawDataSize=-1, COLUMN_STATS_ACCURATE=false, numFiles=2,
transient_lastDdlTime=1472192963}, viewOriginalText:null,
viewExpandedText:null, tableType:MANAGED_TABLE)






> Metastore API - Retrieving PrincipalPrivilegeSet Object using getPrivileges() 
> method inside metastore Table class give Null value
> ---------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HIVE-14687
>                 URL: https://issues.apache.org/jira/browse/HIVE-14687
>             Project: Hive
>          Issue Type: Bug
>          Components: Authorization
>    Affects Versions: 1.2.1
>         Environment: RHEL 6 
>            Reporter: Rahul Dhote
>              Labels: authorization
>             Fix For: 1.2.1
>
>
> During retrieving the privileges associated with table using Hive metastore 
> api, it retrieves all other properties associated with table and gives null 
> for privileges set 
> .[https://hive.apache.org/javadocs/r1.2.1/api/org/apache/hadoop/hive/metastore/api/Table.html]
> Configuration Applied:
> Enable the SQL Authorization inside the Hive Server and user like 
> hive,rootcare added inside admin role through hive configuration.
> Problem:
> Unable to retrieve the privileges for table using getPrivileges() method 
> after connecting through HiveMetastoreClient api. getPrivileges methods 
> return null whereas other properties of table are retrieved. 
> Analysis:
> I created the table using Hive user after connecting to HiveServer2 
> usingJDBC. By Default, after creating the table the default
> privileges are assigned to the current user. It show all the privileges to 
> table from hive prompt using sql.
> Tried to explore the API, found that Table class is generated by thrift and 
> consist of thrift code. I found that privileges field inside the Table class 
> is made optional. Also, found that, the privileges are stored inside the 
> table TBL_PRIVS inside metastore database.
> Is there any specific configuration to be made to retrieve optional field ?
> Options Tried:
> 1. Tried to print the isSetPrivilege() property, but it returns null.
> 2. Tried to add user in admin role which is connecting to hive metastore. 
> Still it gives the getPrivileges() as null.
> Sample Table Object Output:
> Table(tableName:sr4, dbName:hadoop_schema, owner:hive,
> createTime:1472192882, lastAccessTime:0, retention:0,
> sd:StorageDescriptor(cols:[FieldSchema(name:id, type:int, comment:null),
> FieldSchema(name:status, type:varchar(20), comment:null)], location:hdfs://
> loco1.fyre.com:8020/apps/hive/warehouse/hadoop_schema.db/sr4,
> inputFormat:org.apache.hadoop.mapred.TextInputFormat,
> outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat,
> compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null,
> serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe,
> parameters:{serialization.format=1}), bucketCols:[], sortCols:[],
> parameters:{}, skewedInfo:SkewedInfo(skewedColNames:[], skewedColValues:[],
> skewedColValueLocationMaps:{}), storedAsSubDirectories:false),
> partitionKeys:[], parameters:{totalSize=17, sql.table.io.doAs=false,
> numRows=-1, rawDataSize=-1, COLUMN_STATS_ACCURATE=false, numFiles=2,
> transient_lastDdlTime=1472192963}, viewOriginalText:null,
> viewExpandedText:null, tableType:MANAGED_TABLE)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to