If you need to use Presto SQL during data development, you can configure a Presto SQL job in E-MapReduce (EMR). This topic describes how to configure a Presto SQL job.

Procedure

  1. Log on to the E-MapReduce console by using an Alibaba Cloud account.
  2. In the top navigation bar, select the region and resource groups where your cluster resides.
  3. Click the Data Platform tab.
  4. In the Projects section, click Edit Job in the Actions column of the target project.
  5. Right-click the folder where you want to create a job, and select Create Job.
    Note You can also right-click the folder to create a subfolder, rename the folder, or delete the folder.
  6. In the Create Job dialog box, set the Name and Description parameters and select Presto SQL from the Job Type drop-down list.
    You can use the following command syntax to submit a Presto SQL job:
    presto <options> -f {SQL_SCRIPT}
    Note SQL_SCRIPT refers to the SQL statements that you enter in the job editor.
  7. Click OK.
  8. Specify the command line parameters required to submit the job in the Content field.
    Example:
    SELECT * from table1;
  9. Click Save.

Set Presto CLI parameters

By default, Presto queries data tables under the hive catalog and default schema. You can set Presto command line interface (CLI) parameters to specify catalogs and schemas. You can use one of the following methods to set Presto CLI parameters in a Presto SQL job.

  • Use environment variables.
    • Password: If password authentication is enabled for the Presto service, add the PRESTO_PASSWORD environment variable to specify a password.
    • Other parameters: Set the parameters in the PRESTO_CLI_PARAMS environment variable, for example, PRESTO_CLI_PARAMS="--catalog mysql --schema db1 ".
  • Use custom variables.
    • Password: Add a custom variable named presto.password to the job to specify a password for Presto authentication.
    • Other parameters: Add custom variables in the format of _presto.xxx to the job. The custom variables are added to the Presto CLI parameter list. The corresponding option is in the format of --xxx.

      The following custom variables are supported:

      ## Basic parameters
      * _presto.schema <schema>
      * _presto.catalog <catalog>
      
      ## Control and debugging parameters
      * _presto.trace-token <trace token>
      * _presto.session <session>...
      * _presto.source <source>
      * _presto.resource-estimate <resource-estimate>...
      * _presto.log-levels-file <log levels file>
      
      ## Connection parameters
      * _presto.server <server>
      * _presto.http-proxy <http-proxy>  * ignore-errors
      * _presto.socks-proxy <socks-proxy>
      
      ## Authentication parameters
      * _presto.user <user>
      * _presto.password <password>
      
      * _presto.client-info <client-info>
      * _presto.client-request-timeout <client request timeout>
      * _presto.client-tags <client tags>
      
      * _presto.access-token <access token>
      * _presto.truststore-password <truststore password>
      * _presto.truststore-path <truststore path>
      * _presto.keystore-password <keystore password>
      * _presto.keystore-path <keystore path>
      * _presto.extra-credential <extra-credential>...
      
      ## High-security parameters
      * _presto.krb5-config-path <krb5 config path>
      * _presto.krb5-credential-cache-path <krb5 credential cache path>
      * _presto.krb5-disable-remote-service-hostname-canonicalization
      * _presto.krb5-keytab-path <krb5 keytab path>
      * _presto.krb5-principal <krb5 principal>
      * _presto.krb5-remote-service-name <krb5 remote service name>
      * _presto.krb5-service-principal-pattern <krb5 remote service principal pattern>