Presto Engine

This article mainly introduces the configuration, deployment and use of the Presto engine in Linkis1.X.

If you want to use the Presto engine on your server, you need to prepare the Presto connection information, such as the connection address, username and password of the Presto cluster, etc.

Note: Before compiling the Presto engine, a full build of the Linkis project is required This engine plug-in is not included in the released installation deployment package by default. You can follow this guide to deploy and install https://linkis.apache.org/blog/2022/04/15/how-to-download-engineconn-plugin or follow the steps below to manually compile and deploy

Compile the Presto engine separately

  1. ${linkis_code_dir}linkis-engineconn-plugins/presto/
  2. mvn clean install

The engine package compiled in step 2.1 is located in

  1. ${linkis_code_dir}/linkis-engineconn-pluginsjdbc/target/out/presto

Upload to the engine directory of the server

  1. ${LINKIS_HOME}/lib/linkis-engineplugins

And restart linkis-engineplugin (or refresh through the engine interface)

  1. cd ${LINKIS_HOME}/sbin
  2. sh linkis-daemon.sh restart cg-engineplugin

Check whether the engine refresh is successful: You can check whether the last_update_time of the linkis_engine_conn_plugin_bml_resources table in the database is the time when the refresh is triggered.

  1. #Login to the linkis database
  2. select * from linkis_cg_engine_conn_plugin_bml_resources

Linkis1.X is done through tags, so we need to insert data into our database, and the insertion method is as follows.

  1. -- set variable
  2. SET @PRESTO_LABEL="presto-0.234";
  3. SET @PRESTO_ALL=CONCAT('*-*,',@PRESTO_LABEL);
  4. SET @PRESTO_IDE=CONCAT('*-IDE,',@PRESTO_LABEL);
  5. SET @PRESTO_NAME="presto";
  6. insert into `linkis_cg_manager_label` (`label_key`, `label_value`, `label_feature`, `label_value_size`, `update_time`, `create_time`) VALUES ('combined_userCreator_engineType',@PRESTO_ALL, 'OPTIONAL', 2, now(), now());
  7. insert into `linkis_cg_manager_label` (`label_key`, `label_value`, `label_feature`, `label_value_size`, `update_time`, `create_time`) VALUES ('combined_userCreator_engineType',@PRESTO_IDE, 'OPTIONAL', 2, now(), now());
  8. select @label_id := id from `linkis_cg_manager_label` where `label_value` = @PRESTO_IDE;
  9. insert into `linkis_ps_configuration_category` (`label_id`, `level`) VALUES (@label_id, 2);
  10. INSERT INTO `linkis_ps_configuration_config_key` (`key`, `description`, `name`, `default_value`, `validate_type`, `validate_range`, `engine_conn_type`, `is_hidden`, `is_advanced`, `level`, `treeName`) VALUES ('wds.linkis.presto.url', 'Presto 集群连接', 'presto连接地址', 'http://127.0.0.1:8080', 'None', NULL, @PRESTO_NAME, 0, 0, 1, '数据源配置');
  11. INSERT INTO `linkis_ps_configuration_config_key` (`key`, `description`, `name`, `default_value`, `validate_type`, `validate_range`, `engine_conn_type`, `is_hidden`, `is_advanced`, `level`, `treeName`) VALUES ('wds.linkis.presto.catalog', '查询的 Catalog ', 'presto连接的catalog', 'hive', 'None', NULL, @PRESTO_NAME, 0, 0, 1, '数据源配置');
  12. INSERT INTO `linkis_ps_configuration_config_key` (`key`, `description`, `name`, `default_value`, `validate_type`, `validate_range`, `engine_conn_type`, `is_hidden`, `is_advanced`, `level`, `treeName`) VALUES ('wds.linkis.presto.schema', '查询的 Schema ', '数据库连接schema', '', 'None', NULL, @PRESTO_NAME, 0, 0, 1, '数据源配置');
  13. INSERT INTO `linkis_ps_configuration_config_key` (`key`, `description`, `name`, `default_value`, `validate_type`, `validate_range`, `engine_conn_type`, `is_hidden`, `is_advanced`, `level`, `treeName`) VALUES ('wds.linkis.presto.source', '查询使用的 source ', '数据库连接source', '', 'None', NULL, @PRESTO_NAME, 0, 0, 1, '数据源配置');
  14. -- engine -*
  15. insert into `linkis_ps_configuration_key_engine_relation` (`config_key_id`, `engine_type_label_id`)
  16. (select config.id as `config_key_id`, label.id AS `engine_type_label_id` FROM linkis_ps_configuration_config_key config
  17. INNER JOIN linkis_cg_manager_label label ON config.engine_conn_type = @PRESTO_NAME and label_value = @PRESTO_IDE);
  18. -- engine default configuration
  19. insert into `linkis_ps_configuration_config_value` (`config_key_id`, `config_value`, `config_label_id`)
  20. (select `relation`.`config_key_id` AS `config_key_id`, '' AS `config_value`, `relation`.`engine_type_label_id` AS `config_label_id` FROM linkis_ps_configuration_key_engine_relation relation
  21. INNER JOIN linkis_cg_manager_label label ON relation.engine_type_label_id = label.id AND label.label_value = @PRESTO_IDE);
ConfigurationDefaultDescriptionRequired
wds.linkis.presto.urlhttp://127.0.0.1:8080Presto cluster connectiontrue
wds.linkis.presto.usernamedefaultPresto cluster usernamefalse
wds.linkis.presto.passwordnonePresto cluster passwordfalse
wds.linkis.presto.catalogsystemCatalog for queriestrue
wds.linkis.presto.schemaNoneQuery Schematrue
wds.linkis.presto.sourceglobalsource used by the queryfalse
presto.session.query_max_total_memory8GBquery uses maximum memoryfalse
wds.linkis.presto.http.connectTimeout60Presto client connect timeout (unit: seconds)false
wds.linkis.presto.http.readTimeout60Presto client read timeout (unit: seconds)false
wds.linkis.engineconn.concurrent.limit100The maximum number of concurrent Presto enginesfalse

If the default parameters are not satisfied, there are three ways to configure some basic parameters.

Presto Engine - 图1

Submit the task interface and configure it through the parameter params.configuration.runtime

  1. Example of http request parameters
  2. {
  3. "executionContent": {"code": "show teblas;", "runType": "psql"},
  4. "params": {
  5. "variable": {},
  6. "configuration": {
  7. "runtime": {
  8. "wds.linkis.presto.url":"http://127.0.0.1:9090",
  9. "wds.linkis.presto.catalog ":"hive",
  10. "wds.linkis.presto.schema ":"default",
  11. "wds.linkis.presto.source ":""
  12. }
  13. }
  14. },
  15. "source": {"scriptPath": "file:///mnt/bdp/hadoop/1.sql"},
  16. "labels": {
  17. "engineType": "presto-0.234",
  18. "userCreator": "hadoop-IDE"
  19. }
  20. }

Configure by modifying the linkis-engineconn.properties file in the directory install path/lib/linkis-engineconn-plugins/presto/dist/v0.234/conf/, as shown below:

Presto Engine - 图2

To submit a task through linkis-cli, you need to specify the corresponding EngineConn and CodeType tag types. The use of presto is as follows:

  • Note that the engineType presto-0.234 engine version setting is prefixed to presto-0.234 if the presto version is 0.234
  1. sh ./bin/linkis-cli -engineType presto-0.234 -codeType psql -code 'show tables;' -submitUser hadoop -proxyUser hadoop

If the management console, task interface, and configuration file are not configured, they can be configured in the cli client through the -runtimeMap property

  1. sh ./bin/linkis-cli -engineType presto-0.234 -codeType tsql -code 'show tables;' -runtimeMap wds.linkis.presto.url=http://127.0.0.1:50070 -runtimeMap wds.linkis.presto. catalog=hive -runtimeMap wds.linkis.presto.schema=default -runtimeMap wds.linkis.presto.catalog=hive -submitUser hadoop -proxyUser hadoop

For specific usage, please refer to: Linkis CLI Manual.

Right-click the workspace module and select a new script of type psql

Presto Engine - 图3