In this article

Overview

Use this Snap to add a MINUS SQL operator to the separate queries coming from upstream Snaps. The MINUS SQL operator corresponds to ANSI EXCEPT. In Azure Synapse and BigQuery, this Snap uses the EXCEPT operation unlike in Redshift and Snowflake, where the Snap uses the MINUS operation. This Snap also allows you to preview the result of the MINUS SQL operation on the incoming SQL queries. You can validate the modified query using this preview functionality.

  • The MINUS SQL operation does not eliminate duplicate records. You can add the ELT Unique Snap to the ELT Minus Snap to remove duplicates. 
  • This Snap's output is not commutative. The Snap's output changes based on which table is connected in which input view. For example, if you use queries for tables A and B as inputs, where query A is connected to the first input and query is connected to the second, the result from the Snap's execution would not be the same if it was the other way around. Basically, A MINUS B is not the same as B MINUS A.

Prerequisites

None.

Limitation

Known Issues

Snap Input and Output

Input/OutputType of ViewNumber of ViewsExamples of Upstream and Downstream SnapsDescription
Input 

Document

  • Min: 2
  • Max: No limit
  • ELT Select
  • ELT Aggregate
Multiple SQL queries.
Output

Document

  • Min: 1
  • Max: 1
  • ELT Unique
  • ELT Insert-Select
The incoming SQL queries with the MINUS operator included. 

Snap Settings

Parameter NameData TypeDescriptionDefault ValueExample 
LabelString
ELT MinusExclude Common Records
Get preview dataCheckbox

In Azure Synapse and BigQuery, this Snap uses EXCEPT operation unlike in Redshift and Snowflake, wherein the Snap uses MINUS operation.


Output preview in Azure Synapse


Not selectedSelected
Retain duplicates (Databricks Lakehouse Platform only)CheckboxIf your target database is a Databricks Lakehouse Platform instance, select this checkbox to indicate that the Snap can include duplicate entries in its output. Else (by default), the Snap retrieves only unique records from the MINUS/EXCEPT operation result.Not selectedSelected

Troubleshooting

None.

Examples

Retrieving Uncommon Rows From a Table

We need a query with the MINUS operator if we want to compare two tables and retrieve the uncommon records from the first table. This example shows how we can use the ELT Minus Snap to build this query.

First, we build SELECT queries to read the target tables. To do so, we can use two ELT Select Snaps, in this example: Read Part A and Read Part B. Each of these Snaps is configured to output a SELECT * query to read the target table in the database. Additionally, these Snaps are also configured to show a preview of the SELECT query's execution as shown:

Read Part A ConfigurationRead Part B Configuration

A preview of the outputs from the ELT Select Snaps is shown below:

Read Part A OutputRead Part B Output

Then, we connect the ELT Minus Snap to the output view of the ELT Select Snaps. The SELECT * queries in both of these Snaps form the inputs for the ELT Minus Snap. Upon execution, the ELT Minus Snap combines both incoming SELECT * queries and adds the MINUS operator.

A preview of the ELT Minus Snap's output is shown below:

We can also add an ELT Insert-Select Snap downstream and write the result of this query into another table.

Download this Pipeline.

Downloads

  1. Download and import the Pipeline into SnapLogic.
  2. Configure Snap accounts as applicable.
  3. Provide Pipeline parameters as applicable.



Edit the Excerpt Include macro below to link to the Snap Pack page for this Snap page. Ensure that the heading Snap Pack History is not within the Snap Pack's history Excerpt. 


See Also

Provide links to the endpoint's official documentation, any relevant or related internal documentation, and any other links you have referred to on this page. Care should be taken when referencing external sites/documentation that it is an official site/documentation. Do not refer to forums such as stackoverflow.