User Tools

Site Tools


Sidebar

**HPL/SQL is included to Apache Hive since version 2.0** * [[home|Home]]\\ * [[why|Why HPL/SQL]]\\ * [[features|Key Features]]\\ * [[start|Get Started]]\\ * [[doc|HPL/SQL Reference]]\\ * [[download|Download]]\\ * [[new|What's New]]\\ * [[about|About]]

cli

====== HPL/SQL Command Line ====== You can run //hplsql// tool from a command line to execute a SQL statement or HPL/SQL script. **Syntax**: <code language="sql"> hplsql -e 'query' | -f file [-main procname] [-d | --define | -hiveconf | -hivevar var=value ...] [-version | --version] [-trace | --trace] [-H | --help] </code> **Parameters:** | **Parameter** || **Description** | **HPL/SQL Version** | | -e 'query' || SQL statements to execute | 0.1 | | -f file || Execute SQL statements from //file// | 0.1 | | -main procname || Entry point (procedure or function name) | 0.3.7 | | -d var=value || Variable definition | 0.1 | | %%--%%define var=value ||:::| 0.1 | | -hiveconf var=value ||:::| 0.1 | | -hivevar var=value ||:::| 0.1 | | -version | %%--%%version | Print HPL/SQL version | 0.1 | | -trace | %%--%%trace | Print trace information | 0.1 | | -H | %%--%%help | Print help information and exit | 0.1 | **Notes**: * -e and -f cannot be specified together * if -main option is not specified, HPL/SQL starts executing all statements from the beginning of the script * You can use single 'query' and double "query" quotes with -e option * Currently -d, %%--%%define, -hivevar and -hiveconf are equivalent and allow you to define input variables. **Example 1:** Executing HPL/SQL statements from a script: <code language="sql"> hplsql -f script.sql </code> **Example 2:** Executing HPL/SQL statements from command line: <code language="sql"> hplsql -e "NVL(MAX_PARTITION_DATE(db.sales, local_dt, code='A'), CURRENT_DATE)" </code> **Example 3:** Using variables: <code language="sql"> hplsql -e "PRINT a || ', ' || b" -d a=Hello -d b=world </code> Result: <code>Hello, world</code>