show_query() | Teradata Package for R - show_query() - Teradata Package for R

Teradata® Package for R User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for R
Release Number
17.20
Published
March 2024
ft:locale
en-US
ft:lastEdition
2024-04-09
dita:mapPath
efv1707506846369.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
nqx1518630623256
Product Category
Teradata Vantage

Use the show_query() function to show the underlying SQL query of analytic functions.

Example

  • Set the option 'val.install.location'.
    > options(val.install.location = "VAL")
  • Get remote data source connection.
    > con <- td_get_context()$connection
  • Create an object of class "tbl_teradata".
    > df <- tbl(con, "customer_analysis")
    > print(df)
  • Run td_decision_tree_valib() on columns "age", "income" and "nbr_children", with dependent variable "gender".
    > obj <- td_decision_tree_valib(data=df,
                                  columns=c("age", "income", "nbr_children"),
                                  response.column="gender",
                                  algorithm="gainratio",
                                  binning=FALSE,
                                  max.depth=5,
                                  num.splits=2,
                                  pruning="gainratio")
  • Print the SQL query.
    > print(obj %>% show_query())
    > # <SQL> call VAL.td_analyze('DECISIONTREE', 'database=ALICE; tablename=customer_analysis;
    > # outputdatabase=ALICE;outputtablename=r__t__valib_td_decision_tree_valib1621181655984242; columns=age,income,nbr_children; dependent=gender;
    > # algorithm=gainratio; binning=FALSE; max_depth=5; min_records=2; pruning=gainratio');