Registers a MaxCompute table as a resource so that SQL and MapReduce jobs can reference it at runtime.
This is a CMD statement. Run it on the MaxCompute client (odpscmd) only.
Limitations
External tables cannot be added as resources.
Schema evolution is not supported for tables registered as resources. If a table undergoes schema evolution after being added, remove it and add it again.
Each resource file cannot exceed 2,048 MB.
The total size of resources referenced by a single SQL or MapReduce job cannot exceed 2,048 MB.
Syntax
add table <table_name> [partition (<spec>)] [as <alias>] [comment '<comment>'] [-f];Parameters
| Parameter | Required | Description |
|---|---|---|
table | Yes | The resource type. For more information about resource types, see Resource. |
table_name | Yes | Name of the MaxCompute table to register as a resource. |
spec | Required for partitioned tables | Partition to register. Only the specified partition is registered — not the entire table. Use the format partition_column='value', for example, ds='20150602'. |
alias | No | Resource name. Defaults to the file name if not specified. Not supported for JAR or Python script resources. |
comment | No | Description of the resource. |
-f | No | Overwrites the existing resource if a resource with the same name already exists. Without this flag, adding a resource with a duplicate name fails. |
Examples
Add a partitioned table as a resource
Register a single partition of sale_detail as a resource named sale.res, and force-overwrite if the resource already exists:
add table sale_detail partition (ds='20150602') as sale.res comment 'sale detail on 20150602' -f;Expected output:
OK: Resource 'sale.res' have been updated.What's next
After registering a table as a resource, reference it by name in MapReduce jobs or UDFs. To manage your resources, see the following statements:
DESC RESOURCE: View details about a resource.
LIST RESOURCES: List all resources in the project.
ALIAS: Create an alias for a resource.
GET RESOURCE: Download a resource.
DROP RESOURCE: Delete a resource.
Related ADD statements:
ADD ARCHIVE: Add an archive file as a resource.
ADD FILE: Add a file as a resource.
ADD JAR: Add a JAR file as a resource.
ADD PY: Add Python code as a resource.