Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 53 additions & 73 deletions src/connections/storage/warehouses/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,99 +22,79 @@ Segment's libraries pass nested objects and arrays into tracking calls as **prop
- The warehouse connector optionally stringifies **arrays** when they follow the [Ecommerce spec](/docs/connections/spec/ecommerce/v2/)
- The warehouse connector "flattens" all **context fields** that contain a nested **object** (for example, context.field.nestedA.nestedB becomes a column called context_field_nestedA_nestedB)

<table>
<thead>
<tr>
<th> Field </th>
<th> Code (Example) </th>
<th> Schema (Example) </th>
</tr>
</thead>

<tr>
<td><b>Object (Context):</b> Flatten </td>
<td markdown="1">

``` json
context: {
app: {
version: "1.0.0"
### Schema objects

The following examples show how Segment transforms nested objects and arrays into warehouse columns.

#### Context

**Type:** Object

```json
{
"context": {
"app": {
"version": "1.0.0"
}
}
}
```
</td>
<td>
<b>Column Name:</b><br/>
context_app_version
<br/><br/>
<b>Value:</b><br/>
"1.0.0"
</td>
</tr>

<tr>
<td> <b>Object (Traits):</b> Flatten </td>
<td markdown= "1">

Segment flattens nested objects in context fields.

**Result:** Column `context_app_version` with value `"1.0.0"`

#### Traits

**Type:** Object

```json
traits: {
address: {
street: "6th Street"
{
"traits": {
"address": {
"street": "6th Street"
}
}
}
```

</td>
<td>
<b>Column Name:</b><br/>
address_street<br/>
<br/>
<b>Value:</b><br/>
"6th Street"
</td>
</tr>
Segment flattens nested objects in traits.

<tr>
<td><b>Object (Properties):</b> Flatten</td>
<td markdown="1">
**Result:** Column `address_street` with value `"6th Street"`

#### Properties

**Type:** Object

```json
properties: {
product_id: {
sku: "G-32"
{
"properties": {
"product_id": {
"sku": "G-32"
}
}
}
```
</td>
<td>
<b>Column Name:</b><br/>
product_id_sku<br/><br/>
<b>Value:</b><br/>
"G-32"
</td>
</tr>

<tr>
<td><b>Array (Any):</b> Stringify</td>
<td markdown="1">

Segment flattens nested objects in properties.

**Result:** Column `product_id_sku` with value `"G-32"`

#### Array (String)

**Type**: String array

```json
products: {
product_id: [
"507f1", "505bd"
]
{
"products": {
"product_id": ["507f1", "505bd"]
}
}
```

</td>
<td>
<b>Column Name:</b> <br/>
product_id <br/><br/>
<b>Value:</b>
"[507f1, 505bd]"
</td>
</tr>
</table>
Segment stringifes arrays.

**Result:** Column `product_id` with value `"[507f1, 505bd]"`

## Warehouse tables

Expand Down
Loading