本文共 2373 字,大约阅读时间需要 7 分钟。
GRANT/REVOKE ...SHOW GRANTS/ACL/PACKAGE/LABEL/ROLE/PRINCIPALSSHOW PRIV/PRIVILEGESLIST/ADD/REOVE USERS/ROLES/TRUSTEDPROJECTSDROP/CREATE ROLECLEAR EXPIRED GRANTSDESC/DESCRIBE ROLE/PACKAGECREATE/DELETE/DROP PACKAGEADD ... TO PACKAGEREMOVE ... FROM PACKAGEALLOW/DISALLOW PROJECTINSTALL/UNINSTALL PACKAGELIST/ADD/REMOVE ACCOUNTPROVIDERSSET LABLE ...
SecurityManager.runQuery()
来运行 。 SecurityManager
类在 odps-sdk-core 中,因此在使用时请添加依赖: com.aliyun.odps odps-sdk-core 0.29.11-oversea-public
test_label
列的访问级别为 2,也就是运行命令 SET LABEL 2 TO TABLE test_label(key, value);
。 import com.aliyun.odps.Column;import com.aliyun.odps.Odps;import com.aliyun.odps.OdpsException;import com.aliyun.odps.OdpsType;import com.aliyun.odps.TableSchema;import com.aliyun.odps.account.Account;import com.aliyun.odps.account.AliyunAccount;import com.aliyun.odps.security.SecurityManager;public class test { public static void main(String [] args) throws OdpsException { try { // init odps Account account = new AliyunAccount("运行结果:", " "); Odps odps = new Odps(account); odps.setEndpoint("http://service-corp.odps.aliyun-inc.com/api"); odps.setDefaultProject(" "); // create test table // if u already have a table, skip this TableSchema schema = new TableSchema(); schema.addColumn(new Column("key", OdpsType.STRING)); schema.addColumn(new Column("value", OdpsType.BIGINT)); odps.tables().create("test_label", schema); // set label 2 to table columns SecurityManager securityManager = odps.projects().get().getSecurityManager(); String res = securityManager.runQuery("SET LABEL 2 TO TABLE test_label(key, value);", false); System.out.println(res); } catch (OdpsException e) { e.printStackTrace(); } }}
转载地址:http://xqdja.baihongyu.com/