---
schema_version: "1"
id: 0ed308ca51725883455b672a1edaf7b95887dd5732622ee414fb69e10cd789bd
title: Supported Validations for DBT Segments
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/connectapi/guides/features_cdp_dbt_validations.md
canonical_url: https://developer.salesforce.com/docs/data/connectapi/guide/features_cdp_dbt_validations.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 02bca8307160b4de3bceef0e0d573aec9466ec383a0e75a502aae42814355c0f
products:
  - Data 360 Connect REST API
  - Data 360 Developer Documentation
---
# Supported Validations for DBT Segments

To create a segment, use the [POST `/ssot/segments`](https://developer.salesforce.com/docs/data/connectapi/references/spec?meta=createSegment) endpoint. To update a segment, use the [PATCH `/ssot/segments/{segmentApiName}`](https://developer.salesforce.com/docs/data/connectapi/references/spec?meta=updateSegment) endpoint.

When creating or updating a segment, the `sql` property is subject to these validations.

- Only the primary key of the SegmentOn DMO is allowed in the `select` statement. The first table in the join clause must be a profile table.

  - No aggregation (min, max, avg, count) is allowed at the top-level select.

    ```sql
    ---FAIL
    select max(Individual_dense_viv__dlm.age__c) from Individual_dense_viv__dlm
    ---FAIL
    select count(Individual_dense_viv__dlm.individualid__c) from Individual_dense_viv__dlm
    ```

  - No select all (\*) expression is allowed in the top-level select.

    ```sql
    ---FAIL
    select * from Individual_dense_viv__dlm
    ```

  - Only the primary key of the segment on table (the first table in the `from` clause of the sql statement) can be selected.

    ```sql
     ---PASS
    select Individual_dense_viv__dlm.individualid__c from Individual_dense_viv__dlm
    ```

  - Multiple columns can’t be selected even if one of them is the primary key of the table.

    ```sql
    ---FAIL
    select Individual_dense_viv__dlm.individualid__c,
    Individual_dense_viv__dlm.age__c from Individual_dense_viv__dlm
    ```

  - No `case` statements are allowed in the primary `select`.

    ```sql
    ---FAIL
    select
      case
          when Individual_dense_viv__dlm.individualid__c > 10 then Individual_dense_viv__dlm.individualid__c
          else null
      end
    from
      Individual_dense_viv__dlm
    ```

  - If the primary key of the `segmentOn` object has key qualifiers, you must project the key qualifiers, as well, in the primary `select`. First project the primary key and then the qualifier. Group bys must also include the key qualifiers.

    ```sql
    ---PASS
    select Individual__dlm.id__c, Individual__dlm.fq__id__c from Individual__dlm
    ```

  - If the primary key of the `segmentOn` object has key qualifiers, you can provide an additional condition in the join on condition.
    ```sql
    ---PASS
    select Individual__dlm.id__c from Individual__dlm left join Sales__dlm on Individual__dlm.id__c = Sales__dlm.soldToCustomerId__c and Individual__dlm.kq__id__c is not distinct from Sales__dlm.kq__soldToCustomerId__c
    ```

- All columns must be fully qualified by table name in the query and subselect queries.

  ```sql
  ---FAIL
  select individualid__c from Individual_dense_viv__dlm
  ```

- Subqueries are supported only in a `where` clause and must emit only one column.

  ```sql
  ---FAIL
  select Individual_dense_viv__dlm.individualid__c from (select * from Individual_dense_viv__dlm)
  ```

- Compare columns of the same data type. To compare columns of different data types, cast one or both of the operands so that they have the same type.

  ```sql
  ---PASS
  select t.id__c from Individual__dlm as t where cast(t.id__c as varchar(100)) = t1.name
  ```

- `limit` and `offset` are supported.

  ```sql
  ---PASS
  select Individual_dense_viv__dlm.individualid__c from Individual_dense_viv__dlm limit 10
  ```

- Any SQL statement other than the `select` statement isn’t allowed.

  ```sql
  ---FAIL
  update Individual_dense_viv__dlm set Individual_dense_viv__dlm.individualid__c = 'aa'
  ```

- Aliases are not supported.

  ```sql
  ---FAIL
  select t.id__c from Individual__dlm as t
  ```

- To join two DMOs, there must be a relationship between the DMOs, and you must use one of their related join keys in the join on condition. The join on condition can contain only an equality comparison between the joining keys and an optional additional condition for comparing FQK fields.

  ```sql
  ---PASS
  select Individual__dlm.id__c from Individual__dlm left join Sales__dlm on Individual__dlm.id__c = Sales__dlm.soldToCustomerId__c

  --PASS
  Individual__dlm left join Sales__dlm on Individual__dlm.id__c = Sales__dlm.soldToCustomerId__c and Individual__dlm.kq__id__c is not distinct from Sales__dlm.kq__soldToCustomerId__c
  ```
