truncate

ETLUnit 3.9.6

 

Draft in Progress

This document is a draft and is under development.

 

Description

  • Removes all data from a database table.

Attributes

  

 

 

 

 

- >> REF:

 Database Feature Module - Configuration

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

default-implementation-id:  - >> TYPE:  string

implementation-defaults- >> TYPE:  object (key-value pairs, comma-separated)

{

<implementation-default-name>:  - >> TYPE:  string

{

server-name- >> TYPE:  string

server-port- >> TYPE:  integer

implementation-properties:  - >> TYPE:  object (key-value pairs, comma-separated)

user-name- >> TYPE:  string

password- >> TYPE:  string or null

}, ... multiple implementation defaults possible

}

default-connection-id- >> TYPE:  string

data-file-null-delimiter- >> TYPE:  string

data-file-column-delimiter- >> TYPE:  string

data-file-row-delimiter- >> TYPE:  string

database-definitions:   - >> TYPE:  object (key-value pairs, comma-separated)

{

<database-name>  - >> TYPE:  string

{

implementation-id:  - >> TYPE:  string

server-name- >> TYPE:  string

server-port- >> TYPE:  integer

implementation-properties- >> TYPE:  object (key-value pairs, comma-separated)

user-name- >> TYPE:  string

password- >> TYPE:  string or null

schema-scripts:    - >> TYPE:  list of strings

}, ...  multiple database definitions possible

}


 

target:  - >> TYPE:  string  - - > REQUIRED

connection-id:  - >> TYPE:  string

schema:  - >> TYPE:  string

mode:  - >> TYPE:  string

Examples

Prerequisites

  • etlunit-core dependency in POM.
  • etlunit-database dependency in POM.
    • This dependency may be secondary.  
    • For instance, if you declare a dependency on etlunit-sql-server-database, Maven will import the etlunit-database dependency for you.

 

<dependencies>
	<dependency>
		<groupId>org.bitbucket.bradleysmithllc.etlunit</groupId>
		<artifactId>etlunit-core</artifactId>
		<version>${etlunit.project.version}</version>
	</dependency>
    <dependency>
        <groupId>org.bitbucket.bradleysmithllc.etlunit</groupId>
        <artifactId>etlunit-database</artifactId>
        <version>${etlunit.project.version}</version>
    </dependency> 
 </dependencies>

 

Simplest truncate() Example

 

Example of simplest truncate operation

@Database(id: 'qpt_pet', modes: ['src'])

class truncate_operation

{

@Test

truncateDemoBareEssentials()

{

stage(

source: 'BUCKET_GAP_FILLER_FF_SIMPL_TRUNC',

connection-id:'qpt_pet',

target-table: 'BUCKET'

);

 

assert(

source-table: 'BUCKET',

connection-id:'qpt_pet',

assertion-mode: 'notEmpty'

);

 

truncate(

target: 'BUCKET'

);

 

assert(

source-table: 'BUCKET',

connection-id:'qpt_pet',

assertion-mode: 'empty'

);

}

}

 

Example of truncate() showing all possible properties

 

Example of truncate with all possible properties

@Database(id: 'qpt_pet', modes: ['src'])

class truncate_operation

{

@Test

truncateDemoAll()

{

stage(

source: 'BUCKET_GAP_FILLER_FF_SIMPL_TRUNC',

connection-id:'qpt_pet',

target-table: 'BUCKET'

);

 

assert(

source-table: 'BUCKET',

connection-id:'qpt_pet',

assertion-mode: 'notEmpty'

);

 

truncate(

target: 'BUCKET',

connection-id: 'qpt_pet',

schema: 'dbo',

mode: 'src'

);

 

assert(

source-table: 'BUCKET',

connection-id:'qpt_pet',

assertion-mode: 'empty'

);

}

}