Customer Portal

File url with timestamp for delimited_data_writer

Comments 2

  • Avatar
    avackova
    0
    Comment actions Permalink
    Hello Amit,
    you can use auto filling field in your reader with row_timestamp or reader_timestamp function (see auto_filling), and then partitionKey in your writer (see Data Writer).
    See following graph as an example:
    <?xml version="1.0" encoding="UTF-8"?>
    <Graph name="Testing DB Unload" >
    <Global>
    <Metadata id="Metadata0" >
    <Record fieldDelimiter=";" name="employee" recordDelimiter="\n" recordSize="-1" type="delimited">
    <Field name="employee_id" nullable="true" shift="0" type="integer"/>
    <Field name="full_name" nullable="true" shift="0" type="string"/>
    <Field auto_filling="reader_timestamp" format="HHmmss" name="time" type="date"/>
    </Record>
    </Metadata>
    <Metadata id="Metadata1" >
    <Record fieldDelimiter=";" name="employee" recordDelimiter="\n" recordSize="-1" type="delimited">
    <Field name="employee_id" nullable="true" shift="0" type="integer"/>
    <Field name="full_name" nullable="true" shift="0" type="string"/>
    <Field name="time" type="string"/>
    </Record>
    </Metadata>
    <Connection dbConfig="${CONN_DIR}/postgre.cfg" id="Connection0" type="JDBC"/>
    <Property fileURL="workspace.prm" id="GraphParameter0"/>
    </Global>
    <Phase number="1">
    <Node dbConnection="Connection0" id="INPUT" sqlQuery="select * from employee" type="DB_INPUT_TABLE"/>
    <Node append="false" excludeFields="time" fileURL="${DATAOUT_DIR}/employees." id="OUTPUT" partitionFileTag="keyNameFileTag" partitionKey="time" type="DATA_WRITER"/>
    <Node id="REFORMAT0" type="REFORMAT">
    <attr name="transform"><![CDATA[//#TL

    // Transforms input record into output record.
    function transform() {
    $0.employee_id := $0.employee_id;
    $0.full_name := $0.full_name;
    $0.time := date2str($0.time, "HH-mm-ss") + ".dat";
    }

    ]]></attr>
    </Node>
    <Edge debugMode="true" fromNode="INPUT:0" id="INEDGE" inPort="Port 0 (in)" metadata="Metadata0" outPort="Port 0 (out)" toNode="REFORMAT0:0"/>
    <Edge fromNode="REFORMAT0:0" inPort="Port 0 (in)" metadata="Metadata1" outPort="Port 0 (out)" toNode="OUTPUT:0"/>
    </Phase>
    </Graph>
  • Avatar
    mzatopek
    0
    Comment actions Permalink
    Probably the most easiest way how to reach your goal is to exploit the new functionality, which is available since 2.8 version. Consider the CTL statement in an arbitrary component attribute:

    fileURL="${DATAOUT_DIR}/result`date2str(today(), "ddMMyyyy")`.txt"

    This is probably exactly what you need ;)

Please sign in to leave a comment.