All Products
Search
Document Center

Graph Compute:Preparations

Last Updated:Oct 20, 2023

This topic describes the preparations that you must complete before you use Graph Compute.

Prerequisites

  • An Alibaba Cloud account is created. For more information about how to create an Alibaba Cloud account

Grant permissions to a RAM user

  • If you use a Resource Access Management (RAM) user to create, manage, and view Graph Compute instances, you must use the Alibaba Cloud account to which the RAM user belongs to attach one of the following policies to the RAM user based on your business requirements:

    • Policies:

      • AliyunGraphcomputeFullAccess: the permissions to manage Graph Compute.

      • AliyunGraphcomputeReadOnlyAccess: the read-only permissions on Graph Compute.

  • Procedure

    • 1. Attach the required policy to the RAM user.

      • https://ram.console.aliyun.com/permissions/new

        Authorization
    • 2. View the permissions that are granted to the RAM user.

      • https://ram.console.aliyun.com/policies

      Permissions on Graph Compute
    • 3. Grant the RAM user the read-only permissions on Virtual Private Cloud (VPC) resources.

      • If the network type of your Graph Compute instance is VPC, you also need to attach the AliyunVPCReadOnlyAccess policy to the RAM user to grant the RAM user the read-only permissions on VPC resources.

Grant permissions on a data source

  • If you use a MaxCompute data source, you must grant the required permissions to the ALIYUN$openias account of Graph Compute. For more information, see Grant permissions on offline storage to Graph Compute.

    • Note: The ALIYUN$openias account is used to manage MaxCompute resources for the iGraph engine system. You can use this account to build indexes for MaxCompute data.

  • Supported data types

    • The following table describes the supported data types of fields in MaxCompute V1.0 and V2.0.

    MaxCompute version

    MaxCompute data type

    Supported by iGraph

    Mapped data type in iGraph

    Basic data types of MaxCompute V1.0

    BIGINT

    INT64

    DOUBLE

    DOUBLE

    DECIMAL

    We recommend that you use the fields of the STRING and DOUBLE types.

    Note: If you use the fields of the NUMERIC type, make sure that forcible type conversion can be performed on the fields within the specified precision range. Otherwise, the conversion fails, or precision loss occurs.

    STRING

    STRING

    DATETIME

    STRING

    BOOLEAN

    STRING

    Basic data types of MaxCompute V2.0

    TINYINT

    INT8

    SMALLINT

    INT16

    INT

    INT32

    BIGINT

    INT64

    BINARY

    Not recommended.

    Note: The size of a field of this type cannot exceed 2 MB.

    FLOAT

    We recommend that you use the fields of the FLOAT type.

    DOUBLE

    We recommend that you use the fields of the DOUBLE type.

    DECIMAL(precision,scale)

    We recommend that you use the fields of the STRING and DOUBLE types.

    Note: If you use the fields of the NUMERIC type, make sure that forcible type conversion can be performed on the fields within the specified precision range. Otherwise, the conversion fails, or precision loss occurs.

    VARCHAR(n)

    We recommend that you use the fields of the STRING type.

    Note: If you use the fields of the NUMERIC type, make sure that forcible type conversion can be performed on the fields.

    CHAR(n)

    STRING

    STRING

    STRING

    DATE

    We recommend that you use the fields of the STRING type.

    Note: The returned result from iGraph is the current time in the UNIX time format. It is the number of days that have elapsed since 00:00:00 Thursday, 1 January 1970.

    DATETIME

    We recommend that you use the fields of the STRING and INT64 types.

    Note: By default, the returned result from iGraph is a string in the UNIX time format. Unit: milliseconds.

    TIMESTAMP

    We recommend that you use the fields of the STRING and INT64 types.

    Note: By default, the returned result from iGraph is a string in the UNIX time format. Unit: seconds.

    BOOLEAN

    STRING

    Complex data types of MaxCompute V1.0 and V2.0

    ARRAY

    Unsupported

    MAP

    Unsupported

    STRUCT

    Unsupported

Note:

  1. For a MaxCompute data source, iGraph converts the types of the full data, but not the incremental data. You need to manually convert the types of the incremental data before the incremental data is written. This ensures that the types of the incremental data are consistent with those of the full data.

  2. The MaxCompute tables must not contain fields of the complex ARRAY, MAP, or STRUCT type. Otherwise, indexes cannot be built.

Create a data source

If you want to process full data on a regular basis by using Graph Compute, you also need to create a MaxCompute project and corresponding data source tables.

Perform the following steps:

  1. Create a MaxCompute project. The region of the project must be the same as that of the Graph Compute instance.

    • Make sure that the Alibaba Cloud account or RAM user that you use activates DataWorks and MaxCompute and the regions of the services are the same. You can activate DataWorks on the buy page. For more information about how to activate MaxCompute, see Activate MaxCompute and DataWorks.

    • If you want to create a MaxCompute project as a RAM user, you must obtain the credentials of the RAM user and attach the AliyunDataWorksFullAccess policy to the RAM user.

    • For more information, see Create a MaxCompute project.

  2. Add a workspace member.

    • If you use a RAM user, you must assign a workspace administrator role to the RAM user with the corresponding Alibaba Cloud account or as the project owner. Then, the RAM user can be used to grant the required permissions to the ALIYUN$big_graph account of Graph Compute.

    • For more information, see Add a workspace member and configure roles.

  3. Create a partitioned table.

    • Start the MaxCompute client. For more information, see Start the MaxCompute client.

    • Create a partitioned table.

      1. Note:

        1. You must specify the ds|dt parameter for the partition field of the partitioned table.

        2. You can use the fields of the basic types of MaxCompute V1.0 and V2.0. You cannot use the fields of the complex types of MaxCompute V1.0 and V2.0.

      2. Example:

        create table if not exists bank_data_pt
        (
         age             BIGINT comment 'age',
         job             STRING comment 'job type',
         campaign        BIGINT comment 'number of contacts for the current campaign',
         pdays           DOUBLE comment 'time elapsed after the last contact',
         previous        DOUBLE comment 'number of previous contacts',
         poutcome        STRING comment 'results of previous marketing activities',
         emp_var_rate    DOUBLE comment 'employment variance rate',
         cons_price_idx  DOUBLE comment 'consumer price index',
         fixed_deposit   BIGINT comment 'have a time deposit'
        )partitioned by (ds STRING comment 'partition identity',
  4. Grant the read permissions to the ALIYUN$openias account of Graph Compute.

    4.1. Add a role

    // Add the ALIYUN$openias account.
    add user `ALIYUN$openias`; 
    // Check whether the ALIYUN$openias account is added by running the list users; command.
    list users;

    4.2. Grant the read permissions to the ALIYUN$openias account

    // Grant the read permissions to the ALIYUN$openias account.
    // Replace [project] with your project name.
    // Replace [table] with your table name.
    grant Read ON PROJECT [project] to user `ALIYUN$openias`;
    grant List ON PROJECT [project] to user `ALIYUN$openias`;
    grant Describe ON TABLE [table] to user `ALIYUN$openias`;
    grant Select ON TABLE [table] to user `ALIYUN$openias`;

    4.3. Grant permissions on sensitive fields

    # Explicitly authorize access to the data whose sensitivity level is not higher than level 2 in table t1.
    $ GRANT LABEL 2 ON TABLE t1 TO USER `ALIYUN$openias`;
    
    # Explicitly authorize access to the data whose sensitivity level is not higher than level 3 in the col1 and col2 columns in table t1.
    $ GRANT LABEL 3 ON TABLE t1(col1, col2) TO USER `ALIYUN$openias`;
    
    # Grant the permissions on sensitive fields in the whole project.
    $ set label 4 to user `ALIYUN$openias`;

  5. Import data

For more information, see Import data by using Data Integration.