A service unit from multiple physical tables associates multiple physical tables and configures metadata for the associated fields. You can then develop an API based on this service unit to access data from multiple physical tables simultaneously, enabling union data queries. This topic describes how to create a service unit from multiple physical tables.
Prerequisites
The service unit group has been created. For more information, see Create a Service Project Group.
Metadata creation is necessary when the data source type is HBase 0.9.4/1.1.x/1.2.1/2.x, ElasticSearch, or MongoDB. For more information, see Create Metadata.
You need to purchase the row-level permission feature.
Limits
Metadata configuration for multiple physical tables can be performed through data sources. For supported data sources, see Supported Data Sources for DataService Studio.
Some data sources support row-level permissions. For supported data sources, see Supported Data Sources for DataService Studio.
Permission policies
Both project administrators and developer users can create service units.
Notes
The API created based on this service unit can achieve union data queries only when the field value and field type in the primary physical table and non-primary physical table are the same. Otherwise, union data queries cannot be achieved.
Step 1: select the service unit type
At the top menu bar on the Dataphin home page, select Service > API Development.
In the upper left corner, select the project, click the left-side navigation pane Service Unit, on the Service Unit page, click + Create Service Unit.
In the Create Service Unit dialog box, select Multiple Physical Table Service Unit.
Step 2: Configure parameters for the service unit from multiple physical tables
On the Create Service Unit page, configure the basic information and parameter information of the service unit.
Service unit basic information configuration
Parameter
Description
Service Unit Name
The name of the service unit. The name must meet the following requirements:
Can only contain letters, numbers, and underscores (_).
Starts with a letter.
Length is between 4 and 64 characters.
Service Unit Group
Select the created service unit group.
Mode
The mode is used to define whether the data read by the service unit comes from the development data source or the production data source. The modes include Basic and Dev-Prod modes:
- Basic: In this mode, the service unit can read data only from a data source in the production environment.
- Dev-Prod: In this mode, the service unit can read data from either a data source in the development environment or a data source in the production environment.
You can check the environment where a data source resides on the Data Sources page.
Service Unit Description
Provide a brief description of the service unit. No more than 128 characters.
Max Return Count
The default maximum return count in Dataphin is 1000, with a maximum limit of 10000.
It is used to define the number of records returned when querying data through the API, to avoid excessive data being queried at once, which may cause memory overflow in the Dataphin system. If you need to query more data, you can modify the PageSize parameter value in the SDK for Calling the API to return more data when querying the API.
Add Physical Table
Click Add Physical Table, in the Add New Physical Table dialog box, select data tables based on the data source, and add multiple physical tables that need to read data. For supported data sources, see Supported Data Sources for DataService Studio.

Dataphin defaults to setting the first added physical table as the primary table, but you can also choose another physical table as the primary table.
The calculation logic between multiple physical tables is JOIN. The primary table is the left table in the left join calculation, and other tables are the right tables. Subsequently, you need to select a field from the left table as the foreign key field for multiple physical tables. This field will be used as a parameter when calling the API. If the SQL statement does not contain this field, the API call will fail.
If the existing service unit is similar to the basic information you configured, Dataphin will automatically display the name of the similar service unit for you. You can view the detailed information of the service unit in the service unit list. If you need to continue creating a new service unit, click Continue To Create to enter the Configure Service Unit Fields page.
Configure service unit fields.
Parameter
Description
Configure Service Unit Foreign Key Field
Service Unit Field
You can customize the service unit field name. The name must meet the following requirements:
Can only contain letters, numbers, and underscores (_).
Starts with a letter.
Length is between 4 and 64 characters.
Primary Table Name.foreign Key Field (primary Key)
Select a field from the primary table that has the same field value as the associated non-primary table. This foreign key field will be used as a parameter when calling the API. If the SQL statement does not contain this foreign key field, the API call will fail.
Service Unit Foreign Key Field Type
Select the field type of the associated primary table.
Service Unit Field Description
Provide a brief description of the service unit foreign key field.
Configure Service Unit Fields
Service Unit Field Type
The supported field types include Double, Float, String, Date, Boolean, Int, Long, Short, Byte, BigDecimal, Binary. You need to select the corresponding foreign key field type based on the actual field type of the business data.
If the field type of the business data is not within the above field type range, it is recommended to select String.
Service Unit Field
Configure the mapping of business data fields to the field names in the service unit. You can customize the field name based on the business situation. The name must meet the following requirements:
Can only contain letters, numbers, and underscores (_).
Starts with a letter.
Length is between 4 and 64 characters.
Service Unit Field Description
Provide a brief description of the service unit field.
After completing the configuration of the service unit fields, click Data Preview at the bottom to view the business data corresponding to the fields. A maximum of 1000 records can be returned.
Based on the selected physical data tables, the system automatically parses the row-level permission information associated with the physical data tables, including row-level permission name, description, control field, data source environment, associated table, and associated field. You can also perform the following operations:
Enable or Disable row-level permissions: Control the effective status of row-level permissions and whether the row-level permission list information is visible when viewing the service unit.
Create Row-level Permission: The operator needs to have the permission to create row-level permissions. Click to navigate to the row-level permission creation page in Management Hub > Permission Management to create a new row-level permission.
NoteThe data range returned by calling this API is controlled by row-level permissions. When row-level permissions are inconsistent, there will be differences in the data return results.
When the mode is Basic, the row-level permissions of the physical data tables associated with the production environment are displayed. When the mode is Dev-Prod, the row-level permissions of the physical data tables associated with both the development environment and production environment are displayed.
If the service unit has row-level permissions enabled and has been published, the APIs created under this service unit will be controlled by the corresponding row-level permissions when called.
When creating an API under a service unit with row-level permissions enabled and published, if you create/delete the row-level permissions associated with this service unit in Management Hub > Permission Management, the system will automatically enable/disable the row-level permissions without the need to republish the API.
The added physical tables will be controlled by the row-level permissions associated with the physical tables, regardless of whether the fields of the physical table are applied by the API or added to the service unit.
If different fields from multiple physical tables are associated with the same row-level permission, all fields will be effective.
Click Submit to complete the creation of the service unit from multiple physical tables.
What to do next
On the service unit page, click the Actions column
icon and select Publish to submit the single physical table service unit to the production environment. You can then create an API based on this single physical table service unit. For more information, see Create an API.Once the physical table service unit has been created, you can edit, publish, or delete it on the service unit page. For more information, see Manage Service Units.