Learn to configure the <output_transform>
element for Pull Reports™ Ad Hoc
report and data service software.
Catalog Configuration Java API analog:
ColumnConfigurationBuilder#setOutputTransform
An <output_transform>
contains a template to transform the value of the parent <column>
in the
Export Report REST API via database functions
and/or operations. Within the template, use the required ${this}
to reference the column
just as one would in a SQL select clause. At
report runtime, each ${this}
of the output transform will be substituted with the
fully qualified column name (table alias plus column name). The substituted transform will then be used within
the report SQL statement instead of the column name.
Use an <output_transform>
when the native transformation of the raw database
data type to a String is undesirable. A common example is the transformation of database
date or time type to a date formatted string.
Since the value of <output_transform>
is placed directly within the SQL statement,
be sure that all functions and operators are compatible with the underlying database,
and it is free from SQL injection risk.
The following table contains Pull Reports™ XML Catalog file fragments configured with <output_transform>
s
and the resultant SQL query used by the Export Report REST API.
<output_transform>
s and the resulting SQLReport XML | SQL |
---|---|
<table id="table" displayName="Table" name="tname"> <column id="height_ft" name="height_inches" displayName="Height Feet" paramType="java.lang.Double"> <output_transform> case when ${this} is null then null else ${this} / 12 end </output_transform> </column> </table> | select |
<table id="table" displayName="Table" name="tname"> <column id="updated" name="last_updated" displayName="Last Updated" paramType="java.sql.Timestamp"> <output_transform> to_char(${this},'YYYY-MM-DD') </output_transform> </column> </table> | select |
<table id="table" displayName="Table" name="tname"> <column id="upper_fullname" name="full_name" displayName="Full Name"> <output_transform>upper(${this})</output_transform> </column> </table> | select |
<table id="table" displayName="Table" name="tname"> <column id="twice_amount" name="amount" displayName="Twice Amount"> <output_transform> ${this} + ${this} </output_transform> </column> </table> | select |
<table id="table" displayName="Table" name="tname"> <column id="bbox" name="geom" displayName="Bounding Box KML"> <output_transform> st_askml(st_envelope(${this})) </output_transform> </column> </table> | select |
The following table demonstrates how the applyToSort
attribute
effects the resultant Export Report REST API SQL query when used in conjunction
with a sort
parameter on the same <column>
.
<output_transform>
applyToSort
attribute and the resulting SQLReport XML | sort param | SQL |
---|---|---|
<table id="table" displayName="Table" name="tname"> <column id="updated" name="last_updated" displayName="Last Updated" paramType="java.sql.Timestamp"> <output_transform> to_char(${this},'MM-DD-YYYY') </output_transform> </column> </table> | sort=/table@updated | select |
<table id="table" displayName="Table" name="tname"> <column id="updated" name="last_updated" displayName="Last Updated" paramType="java.sql.Timestamp"> <output_transform applyToSort="false"> to_char(${this},'MM-DD-YYYY') </output_transform> </column> </table> | sort=/table@updated | select |
<column>
|
If false, the <output_transform>
is not applied to the SQL
order by
clause when the parent
<column>
is included within the
Export Report REST API sort
parameter
or <export_config>
defaultSort attribute.
It is common to set applyToSort='false'
when applying an <output_transform>
to a <column>
of paramType='java.sql.Date'
. In this case,
the <output_transform>
may transform
the date to a human-readable format (e.g. MM-dd-YYYY), but the applyToSort='false'
retains the sorting behavior of the raw Date
.