After you install the formats
that SAS supplies in libraries inside the Greenplum data warehouse
and publish any custom format definitions that you created in SAS,
you can access the SAS_PUT( ) function with your SQL queries.
If the SQLMAPPUTTO=
system option is set to SAS_PUT (the default) and you submit your
program from a SAS session, the SAS SQL processor maps PUT function
calls to SAS_PUT( ) function references that Greenplum understands.
This example illustrates
how the PUT function is mapped to the SAS_PUT( ) function using
implicit pass-through. The SELECT DISTINCT clause executes inside
Greenplum, and the processing is distributed across all available
data nodes. Greenplum formats the
id
values
with the ANIMAL 20.0 format and processes the SELECT DISTINCT clause
using the formatted values.
/* implicit pass-thru query */
options sqlgeneration=dbms sqlreduceput=none;
options sastrace=',,,d' sastraceloc=saslog
sql_ip_trace=(note,source) msglevel=i;
proc sql noerrorstop reduceput=none details="reduce_put_bench$";
create table fmt_ipout as
select distinct id, put(a,ANIMAL.) len=50 as fmtresult
from dblib.sample ;
quit;
options sastrace=',,,,'
sql_ip_trace=none msglevel=n;
This is a partial listing
of the lines that are written to the SAS log.
/*
GREENPL_1: Prepared:
SELECT * FROM SAMPLE FOR READ ONLY
NOTE: XOG: Put Ping Query
NOTE: SELECT SAS_PUT('ANIMAL', '$IS-INTRINSIC') AS X, SAS_PUT('ANIMAL',
'$FMT-META') AS Y FROM (SELECT COUNT(*) AS C FROM SAMPLE WHERE 0=1)
GREENPL_2: Prepared:
select distinct TXT_1."id", cast(SAS_PUT(TXT_1."a", 'ANIMAL20.0') as char(20))
as fmtresult from SAMPLE TXT_1
SQL_IP_TRACE: pushdown attempt # 1
SQL_IP_TRACE: passed down query:
select distinct TXT_1."id", cast(SAS_PUT(TXT_1."a", 'ANIMAL20.0') as char(20))
as fmtresult from SAMPLE TXT_1
SQL_IP_TRACE: The SELECT statement was passed to the DBMS.
GREENPL_3: Executed:
Prepared statement GREENPL_2
ACCESS ENGINE: SQL statement was passed to the DBMS for fetching data.
*/