send_temp_mac: Send Temp Queries with Mac

Description Usage Arguments Examples

View source: R/send_temp_mac.R

Description

Used to run temp table aka "volatile table" queries from R.
Step 1: Use send_temp_mac() to send temp queries to teradata.
Step 2: Query your temp table(s) using odbc::dbGetQuery() as normal.

Usage

1
send_temp_mac(teradata_connection, temp_query)

Arguments

teradata_connection

A teradata connection created by 'odbc::dbConnect()'

query

A string containing one or multiple temp queries

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Establish connection to teradata
td_con <- dbConnect(odbc::odbc(), "TDXMXF129_64")

# Temp query
temp_query <- "CREATE VOLATILE MULTISET TABLE origination_df AS (
	 SELECT top 100 *
	 FROM DLFIN_FA.monthly_sales_t
 )
WITH DATA PRIMARY INDEX(level_1, level_2, level_3, fiscper) ON  COMMIT  PRESERVE ROWS;

---- Fulfillment data
CREATE VOLATILE MULTISET TABLE fulfillment_df AS (
	 SELECT top 100 *
	 FROM DLFIN_FA.monthly_sales_t
 )
WITH DATA PRIMARY INDEX(level_1, level_2, level_3, fiscper) ON  COMMIT  PRESERVE ROWS;"

# Send the temp queries
send_temp(td_con, temp_query)

# Run final query
final_query <- "select top 100 *
from TDXMXF129.origination_df"
sales_df <- odbc::dbGetQuery(td_con, final_query) %>% as_tibble()

mtfairbanks/graingr documentation built on Nov. 18, 2019, 8:39 a.m.