Go Back
Using Lookup Values in Select Statements
Publisher
: Lingk Inc.
Run In Lingk
Description
This recipe uses a file as a lookup table for values in a specific field. To use this recipe, upload the file into the Local File connector for your Environment.
Browse the knowledge base
Twitter
E-Mail
# _____ _ _____ __ # | __ \ (_) |_ _| / _| # | |__) |___ ___ _ _ __ ___ | | _ __ | |_ ___ # | _ // _ \/ __| | '_ \ / _ \ | | | '_ \| _/ _ \ # | | \ \ __/ (__| | |_) | __/ _| |_| | | | || (_) | # |_| \_\___|\___|_| .__/ \___| |_____|_| |_|_| \___/ # | | # |_| # Project Name - USING LOOKUP VALUES IN SELECT STATEMENTS # Recipe URL - https://app.lingk.io/a/10932/tf/17911 # Description - # This recipe uses a file as a lookup table for values in a specific field. # To use this recipe, upload the file into the Local File connector for your Environment. # example file (lookup.csv) # sfVal,sisVal # A,aa # B,bb # C,cc # D,dd # Industry - Higher Ed # Business Process - Graduate Reporting # Systems - # Connectors - JSON # Data Flows - Single Direction # Connection Type - JSON # Add Recipe notes / Change log information here! # _____ _ # / ____| | | # | | ___ _ __ _ __ ___ ___| |_ ___ _ __ ___ # | | / _ \| '_ \| '_ \ / _ \/ __| __/ _ \| '__/ __| # | |___| (_) | | | | | | | __/ (__| || (_) | | \__ \ # \_____\___/|_| |_|_| |_|\___|\___|\__\___/|_| |___/ # # CONNECTORS specify what data will be pulled into the in-memory database during processing connectors: # JSON Setup - https://help.lingk.io/en/articles/74-json-connector-reference ###### Start: LocalFile Connectors ####### - name: lookups type: localFileReader format: csvFormat properties: fileName: "lookup.csv" ###### End: LocalFile Connectors ####### ###### Start: JSON Connectors ####### - name: sourceDB type: JSON properties: jsonObject: | [ { "key":"A" },{ "key":"B" },{ "key":"C" } ] ###### End: JSON Connectors ####### # ______ _ # | ____| | | # | |__ ___ _ __ _ __ ___ __ _| |_ ___ # | __/ _ \| '__| '_ ` _ \ / _` | __/ __| # | | | (_) | | | | | | | | (_| | |_\__ \ # |_| \___/|_| |_| |_| |_|\__,_|\__|___/ # FORMATS specify how files should be processed as they are being read or written to readFormats: - name: csvFormat type: delimited properties: quoteAllFields: true delimiter: ',' header: true # _____ _ _ _ # / ____| | | | | | # | (___ | |_ __ _| |_ ___ _ __ ___ ___ _ __ | |_ ___ # \___ \| __/ _` | __/ _ \ '_ ` _ \ / _ \ '_ \| __/ __| # ____) | || (_| | || __/ | | | | | __/ | | | |_\__ \ # |_____/ \__\__,_|\__\___|_| |_| |_|\___|_| |_|\__|___/ # STATEMENTS specify how the file should be processed while in memory statements: #******************************************************************** D I S C L A I M E R *********************************************************************************************** # * # Note that in an effort to keep recipes optimized for DPH (Data Processing Hours), print statements should be commented out after development has concluded for a recipe. * # For more information on DPH optimization, please visit the following help article - https://help.lingk.io/en/articles/212-minimizing-data-processing-hours-on-the-lingk-platform * # * #******************************************************************** D I S C L A I M E R *********************************************************************************************** - statement: (dataCount) => select count(*) from lookups #- statement: print dataCount # option #1 - using a join # A left outer join is a method of combining tables. The result includes unmatched rows from only the table that is specified before the LEFT OUTER JOIN clause. - statement: | (data) => select b.key, a.sisVal lookupValue from sourceDB b LEFT OUTER JOIN lookups a ON a.sfVal = b.key #- statement: print data # option #2 - using a subselect to handle lookups - statement: | (data) => select b.key, (select first(a.sisVal) from lookups a where a.sfVal = b.key) lookupValue from sourceDB b #- statement: print data # Add more statements to convert, join, aggregrate, transform, and integrate your data
Salesforce Upsert Example supporting Lookups
Fixed Width Data Processing