---
title: "Collect metadata about SQL query"
method: POST
path: "/api/v1/actions/dataSources/{dataSourceId}/scanSql"
tags: ["Scanning"]
---

# Collect metadata about SQL query

`POST /api/v1/actions/dataSources/{dataSourceId}/scanSql`

## Request

- Base URL: `https://www.gooddata.ai`
- URL: `https://www.gooddata.ai/api/v1/actions/dataSources/{dataSourceId}/scanSql`
- Auth: none declared

It executes SQL query against specified data source and extracts metadata. Metadata consist of column names and column data types. It can optionally provide also preview of data returned by SQL query

## Path parameters

- `dataSourceId` string, required

## Request body

- ScanSqlRequest: A request with SQL query to by analyzed.
  - `sql` string, required: SQL query to be analyzed.

## Response `200`

The result of the scan.

- ScanSqlResponse: Result of scanSql. Consists of array of query columns including type. Sql query result data preview can be attached optionally
  - `columns` SqlColumn[], required: Array of columns with types.
    - `dataType` 'INT' | 'STRING' | 'DATE' | 'NUMERIC' | 'TIMESTAMP' | 'TIMESTAMP_TZ' | 'BOOLEAN' | 'HLL', required: Column data type.
    - `description` string: Column description/comment from database
    - `name` string, required: Column name.
    - `nullValue` string: Value used as sentinel for null values in the column.
  - `dataPreview` array[]: Array of rows where each row is another array of string values.
    - string[]

---

[API](https://skmtc.dev/gooddata/apis/gooddata-cn-oapi-all-api.md) - [All operations](https://skmtc.dev/gooddata/apis/gooddata-cn-oapi-all-api/llms.txt) - [OpenAPI document](https://skmtc.dev/gooddata/apis/gooddata-cn-oapi-all-api/revisions/c728ef303bfb?raw)
