Monday, June 27, 2016

WSO2DAS - Delete all data of a persisted table

Some times when we do analytic work with WSO2 DAS we come across the necessity of clearing data of a specific table instead of deleting whole table and recreating again.

You can use following simple steps to achieve it.
  • Shut down the server if already running.
  • Navigate to [Product_Home]/repository/conf/analytics/analytics-config.xml 
  • Find the child element <analytics-data-purging> under </analytics-dataservice-configuration>.
  • If my table name is FOO_TABLE , provide following attributes
 <analytics-data-purging>
      <purging-enable>true</purging-enable>
      <cron-expression>0 0/1 * * * ?</cron-expression>
      <purge-include-tables>
         <table>FOO_TABLE</table>
      </purge-include-tables>
      <data-retention-days>-1</data-retention-days>
   </analytics-data-purging>

Here cron expression is used to specify a time which the purging going to happen. You can read more about cron expressions using [http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-06.html]

After specifying above restart the server and data will be purged corresonding to the cron expression. You need to shutdown the server and make the above to default values so that your data in the table will not be purged again.