Hive - Execute

Overview

You can use the Hive - Execute Snap to execute arbitrary SQL. This Snap enables you to execute simple DML (SELECT, INSERT, UPDATE, DELETE) type statements. For the comprehensive scripting functionality offered by the various databases, you should use the stored procedure functionality offered by their chosen database in the Stored Procedure Snap.
Note: This Snap works only with single queries.
Warning: You can drop your database when working with queries, so be cautious.


Limitations and known issues

The Hive Snap Pack does not validate with Apache Hive JDBC v1.2.1 JARS or earlier because of a defect in Hive. HDP 2.6.3 and HDP 2.6.1 run on Apache Hive JDBC v1.2.1 JARs.

"Method not supported" error is displayed when validating Apache Hive JDBC v1.2.1 or earlier. To validate Snaps that must work with HDP 2.6.3 and HDP 2.6.1, use JDBC v2.0.0 JARs.

Snap views

View Description Examples of upstream and downstream Snaps
Input

If the input view is defined, then the WHERE clause can substitute incoming values for a particular expression.

Valid JSON Paths that are defined in the where clause for queries/statements will be substituted with values from an incoming document.

Output

The status message of the executed query.

Documents will be written to the error view if the document is missing a value to be substituted into the query/statement.

Error

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the pipeline by choosing one of the following options from the When errors occur list under the Views tab. The available options are:

  • Stop Pipeline Execution Stops the current pipeline execution when an error occurs.
  • Discard Error Data and Continue Ignores the error, discards that record, and continues with the remaining records.
  • Route Error Data to Error View Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap settings

Legend:
  • Expression icon (): Allows using pipeline parameters to set field values dynamically (if enabled). SnapLogic Expressions are not supported. If disabled, you can provide a static value.
  • SnapGPT (): Generates SnapLogic Expressions based on natural language using SnapGPT. Learn more.
  • Suggestion icon (): Populates a list of values dynamically based on your Snap configuration. You can select only one attribute at a time using the icon. Type into the field if it supports a comma-separated list of values.
  • Upload : Uploads files. Learn more.
Learn more about the icons in the Snap settings dialog.
Field / Field set Type Description
Label String

Required. Specify a unique name for the Snap. Modify this to be more appropriate, especially if more than one of the same Snaps is in the pipeline.

Default value: Hive - Execute

Example: Hive - Execute
Hive Configuration Properties Use this field set to configure property-value pairs to set for the SQL statement. The values are used in 'set x=y' statements executed immediately before the SQL.
Property String Specify the name of the configuration property.

Default value: N/A

Example: name

Value String Specify the value of the configuration property.

Default value: N/A

Example: jack

SQL Statement String/Expression Required. Specify the SQL statement to execute on the server. Document value substitution will be performed on literals starting with $ (such as $people.name will be substituted with its value in the incoming document).

The Snap does not allow to inject SQL, such as select * from people where $columName = 'abc'. Only values can be substituted since prepared statements are used for execution, which result, for example, in select * from people where address = ?

Note:
  • We recommend you to add a single query in the SQL Statement field.

  • The '$' sign and identifier characters, such as double quotes (“), single quotes ('), or back quotes (`), are reserved characters and should not be used in comments or for purposes other than their originally intended purpose.

  • If a select query is executed, the query's results are merged into the incoming document and any existing keys will have their values overwritten. On the other hand, the original document is written if there are no results from the query.

Default value: N/A

Example: select * from people LIMIT 10 or select * from people where name = $people.name

Query type Dropdown list/Expression Select the type of query for your SQL statement (Read or Write).

When Auto is selected, the Snap tries to determine the query type automatically. If the execution result of the query is not as expected, you can change the query type to Read or Write.

Default value: Auto

Example: Read

Pass through Checkbox Select this checkbox if you want the input document to be passed through to the output view under the key 'original'. This property applies only to the Execute Snaps with a SELECT statement.

Default status: Selected

Ignore empty result Checkbox Select if you want no document written to the output view when the SELECT operation does not produce any result. If this property is not selected and the Pass through property is selected, the input document will be passed through to the output view.

Default status: Deselected

Number of Retries Integer/Expression Specify the maximum number of retry attempts the Snap must make in case of network failure.
When you set the Number of retries to more than 0, the Snap generates duplicate records when the connection is not established. To prevent duplicate records, we recommend that you follow one of the following:
  • Set the Number of retries to 0 (default value) to prevent duplicate records from being passed downstream while executing a pipeline.

  • Use a Primary key to prevent records from being inserted into the database.

  • Use an Upsert instead of an Insert statement.

Default value: 0

Example: 5

Retry Interval (seconds) Integer/Expression Specify the time interval in seconds between connection attempts.

Default value: 1

Example: 11

Snap execution Dropdown list
Choose one of the three modes in which the Snap executes. Available options are:
  • Validate & Execute: Performs limited execution of the Snap and generates a data preview during pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during pipeline runtime.
  • Execute only: Performs full execution of the Snap during pipeline execution without generating preview data.
  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Default value: Execute only

Example: Validate & Execute

Examples