In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use MaxCompute Java SDK to run security-related commands. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Students who use MaxCompute Console may have used MaxCompute security-related commands. The official documentation contains detailed MaxCompute security guidelines and a summary of security-related statements.
In short, rights management, column-level access control, project space security configuration, and resource sharing across project spaces all fall within the scope of MaxCompute security commands.
To put it more bluntly, commands that begin with the following keywords are MaxCompute security-related operation commands:
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...
So how do you use MaxCompute Java SDK to run these commands that can be run on MaxCompute Console? Do they run in the same way as SQL by creating instance?
Answer: no, these commands are not SQL and cannot be run through SQL Task.
You need to use the interface SecurityManager.runQuery () to run. Detailed SDK Java Doc poke here
The SecurityManager class is in odps-sdk-core, so add dependencies when using:
Com.aliyun.odps odps-sdk-core 0.29.11-oversea-public
Here is an example of how to set the access level of the test_label column of the table to 2 through MaxCompute Java SDK, that is, to run the command
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 ();}
Running result:
After the program has been run, run the 'desc test_lable; `command in MaxCompute Console, and you can see that the set label has already taken effect.
On how to use MaxCompute Java SDK to run security-related commands to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.