# The query language used with data stewardship components and the REST API

You can use Talend Query Language (TQL) with the tDataStewardshipTaskDelete and tDataStewardshipTaskInput components to query and filter the data you want to delete or read from Talend Data Stewardship.

## Syntax in TQL queries

The query statement used to filter tasks on the server is composed of one or several conditions.

A task condition is composed of the following elements:

* a field name, which must be prefixed by record. when referencing records data,
* an operator, and
* a value, which can be any literal value. Use simple quotes around strings, and precede quotes within the string with a backslash.

## The fields you can query with TQL

Field names can be chosen among all custom and metadata fields.

The following table lists the supported metadata fields on tasks:

| Metadata field | Description |
| --- | --- |
| id (string) | Task internal identifier |
| externalID (string) | Task external identifier which helps to access a given<br>task from an external system |
| currentState (string) | Current state of the task in the campaign<br>workflow |
| assignee (string) | userId of the data<br>steward currently assigned to this task |
| targetTransition (string) | Name of the transition chosen by user to move the task<br>to the next step in the campaign workflow |
| completed (boolean) | true if the task is completed (it is in a final state<br>of the workflow) |
| priority (integer) | Priority level of the task, ranging from 0 (Very Low) to 4 (Very High), default is 2 (Medium) |
| dueDate | Timestamp in milliseconds of the task due<br>date |
| matchScore (only for Merging and Grouping<br>campaigns) | Decimal value which shows the highest match score of<br>each group in the source data |
| version (integer) | Integer value of the task version which is incremented<br>whenever the task is updated |
| consumed (boolean) | true if the task<br>has already been processed (so it cannot be processed anymore - unless it is<br>reopened) |
| createdBy (string) | userId of the task<br>creator |
| creationDate (long) | Timestamp in milliseconds of this task creation<br>date |
| lastUpdatedBy (string) | userId of the data<br>steward who did the last update on the task |
| lastUpdateDate (long) | Timestamp in milliseconds of the last update done on<br>the task |
| tags (string) | List of tags entered by the user for this<br>task |
| arbitration (only for Arbitration and Grouping<br>campaigns) | Arbitration choice selected by the data<br>steward |

## Operators supported in TQL

| Operator | Description |
| --- | --- |
| = | Returns a result which matches the value<br>entered. |
| != | Returns a result of any value other than the value<br>entered. |
| &gt; | Returns a result which is greater than the value<br>entered. |
| &gt;= | Returns a result which is greater than or equal to the<br>value entered. |
| &lt; | Returns a result which is less than the value<br>entered. |
| &lt;= | Returns a result which is less than or equal to the<br>value entered. |
| contains | Returns a result which contains the reference<br>value. |
| containsIgnoreCase | Returns a result which contains the reference value<br>(case insensitive). |
| ~ | Returns a result which complies with the reference<br>value based on a regular expression.<br><br>Example: name ~ '^[A-Z\|a-z]\*$' |
| complies | Returns a result which complies with a character-based<br>pattern. For more information, check the documentation about [Character-based patterns Character-based patterns](https://help.qlik.com/talend/en-US/data-stewardship-user-guide/8.0/character-based-patterns).<br><br>Example: record.field1 complies 'aaaa99\_aaaaa9' |
| wordComplies | Returns a result which complies with a word-based<br>pattern. For more information, check the documentation about [Word-based patterns Word-based patterns](https://help.qlik.com/talend/en-US/data-stewardship-user-guide/8.0/word-based-patterns).<br><br>Example: record.field1<br>wordComplies '[word][number]\_[word][digit] |
| between | Returns a result which is within the range of values<br>provided. |
| in | Returns a result in the list of values which matches<br>the expression.<br><br>Example: record.field1 in ['value1', 'value2'] |

For dates comparisons, use the timestamp format for reference values.

For example, you can filter tasks created after 2016-01-01 using the following query:

```
creationDate > 1451659712733
```

## Boolean operators supported in TQL

You can combine or negate conditions using the boolean operators and and or, or the not operator respectively. Parentheses are supported to override default boolean precedence.

For example, you can filter tasks by assignee and have a record field firstname equal to John using the following query:

```
assignee='user1@talend.com' and record.firstName='John'
```

You can also filter tasks by assignee and have a record field firstname equal to De'wayne using the following query:

```
assignee='user2@talend.com' and record.firstName='De\'wayne'
```