<commit_before>---
layout: doc_page
---
A data source is the Druid equivalent of a database table. However, a query can also masquerade as a data source, providing subquery-like functionality. Query data sources are currently only supported by [GroupBy](GroupByQuery.html) queries.

### Table Data Source
The table data source the most common type. It's represented by a string, or by the full structure:

```json
{
	"type": "table",
	"name": <string_value>
}
```

### Query Data Source
```json
{
	"type": "query",
	"query": {
		"type": "groupBy",
		...
	}
}
```<commit_msg>Added section on union data sources<commit_after>---
layout: doc_page
---

## Datasources

A data source is the Druid equivalent of a database table. However, a query can also masquerade as a data source, providing subquery-like functionality. Query data sources are currently supported only by [GroupBy](GroupByQuery.html) queries.

### Table Data Source
The table data source is the most common type. It's represented by a string, or by the full structure:

```json
{
	"type": "table",
	"name": <string_value>
}
```

### Union Data Source
This data source unions two table data sources.

```json
{
       "type": "union",
       "dataSources": ["<string_value1>", "string_value2>"]
}
```

### Query Data Source
```json
{
	"type": "query",
	"query": {
		"type": "groupBy",
		...
	}
}
```
{'fraction_non_alphanumeric': 0.13876651982378854, 'fraction_numerical': 0.0014684287812041115, 'mean_word_length': 4.066914498141264, 'pattern_counts': {'":': 12, '<': 6, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5185977', 'n_tokens_mistral': 431, 'n_tokens_neox': 413, 'n_words': 168}