Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this article

Table of Contents
maxLevel2
absoluteUrltrue

Multiexcerpt include
templateData[]
MultiExcerptNameME_OE_ELT_Snap_Accounts
addpanelfalse
PageWithExcerptELT Aggregate

Overview

Use this Snap to add an INTERSECT SQL operator to the separate queries coming from upstream Snaps. This Snap also allows you to preview the result of the INTERSECT SQL operation on the incoming SQL queries. You can validate the modified query using this preview functionality.

Image Modified 

Note

The INTERSECT SQL operation does not eliminate duplicate records. You can add the ELT Unique Snap to the ELT Intersect Snap to remove duplicates. 

Prerequisites

None.

Limitation

Multiexcerpt include macro
nameME_ELT_GBQ_StandardSQL_UOI
pageELT Copy

Known Issues

Multiexcerpt include macro
nameME_ELT_KI_Underscore_Refs
pageELT Snap Pack

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 Merge Into
  • ELT Insert-Select
The incoming SQL queries joined with the INTERSECT operator. 

Snap Settings

Info
titleSQL Functions and Expressions for ELT

You can use the SQL Expressions and Functions supported for ELT to define your Snap or Account settings with the Expression symbol = enabled, where available. This list is common to all target CDWs supported. You can also use other expressions/functions that your target CDW supports.


Parameter NameData TypeDescriptionDefault ValueExample 
LabelString
Insert excerpt
File Writer
File Writer
nopaneltrue
ELT IntersectCommon Records
Get preview dataCheckbox


Multiexcerpt macro
namegetpreviewdata

Select this checkbox to include a preview of the query's output. The Snap performs limited execution and generates a data preview during Pipeline validation.

In the case of ELT Pipelines, only the SQL query flows through the Snaps but not the actual source data. Hence, the preview data for a Snap is the result of executing the SQL query that the Snap has generated in the Pipeline.

The number of records displayed in the preview (upon validation) is the smaller of the following:

  • Number of records available upon execution of the SQL query generated by the Snap.

  • The value set in the Preview Data Count setting (default is 50 records).

Rendering Complex Data Types in Databricks Lakehouse Platform

Based on the data types of the fields in the input schema, the Snap renders the complex data types like map and struct as object data type and array as an array data type. It renders all other incoming data types as-is except for the values in binary fields are displayed as a base64 encoded string and as string data type.



Not selectedSelected
Retain duplicates (Databricks Lakehouse Platform only)Checkbox

Select this checkbox (when your target database is Databricks Lakehouse Platform) to include duplicate records/values, if any, that match the intersection criteria in the output data set. Else, the Snap does not retain any existing duplicate entries in the output.

Info

This setting is ignored in case of all other supported target databases/CDWs except Databricks Lakehouse Platform.


Not selectedSelected

Troubleshooting

None.

Examples

Retrieving Common Records Between Two Tables

We need a query that combines two SELECT queries with an INTERSECT operator to retrieve common records between two tables. This example shows how we can use the ELT Intersect Snap to achieve this result.

Image Modified

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
Image Modified
Image Modified

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

Read Part A OutputRead Part B Output
Image Modified

Image Modified

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

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

Image Modified

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

Download this Pipeline.

Retaining Duplicate Values/Entries in Intersection Data (Databricks Lakehouse Platform)

In this example Pipeline which connects to a Databricks Lakehouse Platform database, we demonstrate how you can retain duplicate records in the common data that the ELT Intersect Snap produces in the output.

Image Modified

We use two ELT Select Snaps to capture data from the two different datasets that we want to extract common records from.

ELT Select Snap (Source 1)

Image Modified

Snap Output

Image Modified


ELT Select Snap (Source 2)

Image Modified

Snap Output

Image Modified

Let us connect the Snaps (that produce these two datasets) to the two input views of the ELT Intersect Snap. Notice that we have selected the Retain Duplicates (Databricks Lakehouse Platform only) check box to ensure that the Snap includes duplicate matching records in its output view.

ELT Intersect Snap

Image Modified

Snap Output

Image Modified

We can see that the output of this Snap contains exactly four matching records including a duplicate record ("FIRSTNAME": "Bruke", ...)

In the end, we write this list of common records between the two source data sets into a DLP table out_ma_dl_elt_intersect_02 by configuring the ELT Insert Select Snap as shown below:

Image Modified

Download this Pipeline.

Downloads

Note
titleImportant Steps to Successfully Reuse Pipelines
  1. Download and import the Pipeline into SnapLogic.
  2. Configure Snap accounts as applicable.
  3. Furnish Pipeline parameters as applicable.

Attachments
patterns*.slp, *.zip


Insert excerpt
ELT Snap Pack
ELT Snap Pack
nopaneltrue


See Also