Trino is an open source distributed SQL query engine designed to run interactive analytic queries of various data sources. You can create an E-MapReduce (EMR) Trino node to aggregate large amounts of multi-dimensional data or analyze reports. For more information, see Trino overview.
Prerequisites
An EMR cluster is created and the cluster is registered to DataWorks.
Before you create an EMR node and use the EMR node to develop EMR tasks in DataWorks, you must register an EMR cluster to a DataWorks workspace. For more information, see Register an EMR cluster to DataWorks.
(Required if you use a RAM user to develop tasks) The RAM user is added to the DataWorks workspace as a member and is assigned the Development or Workspace Manager role. The Workspace Manager role has more permissions than necessary. Exercise caution when you assign the Workspace Manager role. For more information about how to add a member, see Add workspace members and assign roles to them.
A serverless resource group is purchased and configured. The configurations include association with a workspace and network configuration. For more information, see Create and use a serverless resource group.
A workflow is created in DataStudio.
Development operations in different types of compute engines are performed based on workflows in DataStudio. Therefore, before you create a node, you must create a workflow. For more information, see Create a workflow.
Limits
You can run EMR Trino tasks only on a serverless resource group.
If you want to manage metadata for a DataLake or custom cluster in DataWorks, you must configure EMR-HOOK in your cluster first. If you do not configure EMR-HOOK in your cluster, metadata cannot be displayed in real time, audit logs cannot be generated, and data lineages cannot be displayed in DataWorks. EMR governance tasks also cannot be run. For information about how to configure EMR-HOOK, see Use the Hive extension feature to record data lineage and historical access information.
If you enable Lightweight Directory Access Protocol (LDAP) authentication for Trino, you must log on to the master node of the EMR cluster and download the keystore file in the /etc/taihao-apps/trino-conf directory. Then, perform the following steps to upload the keystore file: Log on to the DataWorks console. In the left-side navigation pane, click Management Center. On the page that appears, select the desired workspace and click Go to Management Center. In the left-side navigation pane of the page that appears, click Cluster Management. Then, find the desired cluster and click the Account Mappings tab. In the upper-right corner of the tab, click Edit Account Mappings. On the page that appears, click Upload Keystore File to upload the keystore file.
Step 1: Create an EMR Trino node
Go to the DataStudio page.
Log on to the DataWorks console. In the top navigation bar, select the desired region. Then, choose in the left-side navigation pane. On the page that appears, select the desired workspace from the drop-down list and click Go to DataStudio.
Find the desired workflow, right-click the name of the workflow, and then choose
.In the Create Node dialog box, configure the Name parameter. Click Confirm. The configuration tab of the EMR Trino node appears.
NoteThe node name can contain only letters, digits, underscores (_), and periods (.).
Step 2: Develop an EMR Trino task
Double-click the name of the created node to go to the configuration tab of the node and perform the following operations to develop a task.
(Optional) Select an EMR cluster
If multiple EMR clusters are registered to your workspace, you must select one from the Engine Instance EMR drop-down list in the upper part of the configuration tab of the node based on your business requirements. If only one EMR cluster is registered to your workspace, the EMR cluster is used to develop tasks.
Configure connectors
Before you query data from MySQL tables, you must configure the built-in MySQL connector. For more information, see MySQL connector.
Before you query data from Hive tables, you must configure the built-in Hive connector. For more information, see Hive connector.
Before you query data from tables of other data sources, you must configure the related connector of the data source. For more information, see Configure a connector.
Develop SQL code
In the SQL editor, enter the code for the node. Example:
-- Use method
-- SELECT * FROM <catalog>.<schema>.<table>;
-- Parameter description
-- <catalog> specifies the name of the desired data source.
-- <schema> specifies the name of the database that you want to use.
-- <table> specifies the name of the table that you want to query.
-- For example, you can execute the following statement to query data from the hive_table table in the default database of the Hive data source.
-- Query data from a Hive table.
SELECT * FROM hive.default.hive_table;
-- For example, you can execute the following statement to query data from the rt_user table in the rt_data database of the MySQL data source.
-- Query data from a MySQL table.
SELECT * FROM mysql.rt_data.rt_user;
-- Perform a join query on the Hive and MySQL tables.
SELECT DISTINCT a.id, a.name,b.rt_name FROM hive.default.hive_table a INNER JOIN mysql.rt_data.rt_user b ON a.id = b.id;
-- Use scheduling parameters to query data from a specific Hive table.
SELECT * FROM hive.default.${table_name};
DataWorks provides scheduling parameters whose values are dynamically replaced in the code of a node based on the configurations of the scheduling parameters in periodic scheduling scenarios. You can define variables in the node code in the ${Variable} format and assign values to the variables in the Scheduling Parameter section of the Properties tab. For information about how to configure the scheduling parameters and the supported formats of scheduling parameters, see Configure and use scheduling parameters and Supported formats of scheduling parameters.
If you want to change the scheduling parameter that is assigned to the variable in the code, click Run with Parameters in the top toolbar. For information about value assignment for the scheduling parameters, see What are the differences in the value assignment logic of scheduling parameters among the Run, Run with Parameters, and Perform Smoke Testing in Development Environment modes?
Run the Trino task
In the toolbar, click the icon. In the Parameters dialog box, select the desired resource group from the Resource Group Name drop-down list and click Run.
NoteIf you want to access a data source over the Internet or a virtual private cloud (VPC), you must use the resource group for scheduling that is connected to the data source. For more information, see Network connectivity solutions.
If you want to change the resource group in subsequent operations, you can click the icon to change the resource group in the Parameters dialog box.
If you use an EMR Trino node to query data, up to 10,000 data records can be returned, and the total size of the returned data records cannot exceed 10 MB.
Click the icon to save the SQL statements.
(Optional) Configure advanced parameters
If you want to modify the execution mode of SQL statements, click Advanced Settings in the right-side navigation pane and configure the parameters described in the following table.
Parameter | Description |
FLOW_SKIP_SQL_ANALYZE | The execution method of SQL statements. Valid values:
|
DATAWORKS_SESSION_DISABLE | This parameter is suitable for testing in the development environment of a DataWorks workspace. Valid values:
|
Step 3: Configure task scheduling properties
If you want the system to periodically run a task on the node, you can click Properties in the right-side navigation pane on the configuration tab of the node to configure task scheduling properties based on your business requirements. For more information, see Overview.
You must configure the Rerun and Parent Nodes parameters on the Properties tab before you commit the task.
Step 4: Commit and deploy the task
After a task on a node is configured, you must commit and deploy the task. After you commit and deploy the task, the system runs the task on a regular basis based on scheduling configurations.
Click the icon in the top toolbar to save the node.
Click the icon in the top toolbar to commit the task on the node.
In the Submit dialog box, configure the Change description parameter. Then, determine whether to review the task code after you commit the task based on your business requirements.
NoteYou must configure the Rerun and Parent Nodes parameters on the Properties tab before you commit the task.
You can use the code review feature to ensure the code quality of the task and prevent task execution errors caused by invalid task code. If you enable the code review feature, the task code that is committed can be deployed only after the task code passes the code review. For more information, see Code review.
If you use a workspace in standard mode, you must deploy the task to the production environment after you commit the task. To deploy a task on a node, click Deploy in the upper-right corner of the configuration tab of the node. For more information, see Deploy nodes.
What to do next
After you commit and deploy the task, the task is periodically run based on the scheduling configurations. You can click Operation Center in the upper-right corner of the configuration tab of the node to go to Operation Center and view the scheduling status of the task. For more information, see View and manage auto triggered nodes.