Creates a package in a MaxCompute project to share tables, resource files, and user-defined functions (UDFs) across projects using package-based access control.
Background information
When an Alibaba Cloud account owns multiple MaxCompute projects and needs to share resources in one project with others, two methods are available:
-
Per-user authorization: Add users from other projects to your project and grant each user individual permissions. Use this approach only when fine-grained access control is required for a specific team member. For the authorization syntax, see ACL-based access control.
-
Package-based access control (recommended for cross-project sharing): The project owner bundles the resources and their associated permissions into a package, then authorizes the owners of other projects to install it. After installation, those project owners decide whether to grant their users access to the package resources.
The following figure illustrates how the package-based access control mechanism works.
Limitations
-
A package can contain a maximum of 1,000 resources.
-
A package can be installed in a maximum of 100,000 MaxCompute projects.
-
A maximum of 100 packages created in one MaxCompute project can be installed in another MaxCompute project.
-
A maximum of 100,000 packages can be created in a MaxCompute project.
-
A maximum of 100,000 packages can be installed in a MaxCompute project.
-
This is a CMD statement and can only be executed on the MaxCompute client (odpscmd).
Syntax
create package <package_name>;
Parameters
| Parameter | Required | Description |
|---|---|---|
package_name |
Yes | The name of the package. Must be unique within the project. Can contain letters, underscores (_), and digits, but cannot start with a digit. To list all packages you have created, run show packages; on the MaxCompute client. |
Examples
In this example, the Alibaba Cloud account Bob@aliyun.com owns test_project_a and needs to share resources in that project with other projects. The following statements switch to the project and create a package named datashare.
-- Switch to the project.
use test_project_a;
-- Create a package.
create package datashare;
What's next
After creating a package, use the following statements to manage it:
-
ADD TO PACKAGE: adds resources to the package.
-
REMOVE FROM PACKAGE: removes resources from the package.
-
ALLOW PROJECT: authorizes other projects to use the package.
-
DISALLOW PROJECT: revokes a project's access to the package.
-
DESCRIBE PACKAGE: views the details of a package.
-
DROP PACKAGE: deletes a package.
-
INSTALL PACKAGE: installs a package in a MaxCompute project.
-
UNINSTALL PACKAGE: uninstalls a package from a MaxCompute project.
-
GRANT: authorizes a user or role to access a package.
-
REVOKE: revokes a user's or role's access to a package.
-
SHOW: lists packages created or installed in a MaxCompute project.