# vectorTableSource

You can use **vectorTableSource** to build layers and widgets using **tables** in your data warehouse that contain:

* **Vector data:**
  * points,
  * lines,
  * polygons
  * etc...

## Usage

```typescript
import {vectorTableSource} from '@carto/api-client';

const data = vectorTableSource({
  accessToken: 'XXX',
  connectionName: 'carto_dw',
  tableName: 'carto-demo-data.demo_tables.chicago_crime_sample'
});
```

## Options

<pre class="language-typescript"><code class="lang-typescript">type VectorTableSourceOptions = {
<strong>  tableName: string;
</strong>  columns?: string[];
  spatialDataColumn?: string;
  aggregationExp?: string;
  filters?: Filters;
  filtersLogicalOperator?: 'and' | 'or'; 
};
</code></pre>

* **tableName**: The fully qualified name (FQN) of the table you want to retrieve from your data warehouse. For example, for a BigQuery connection, `carto-demo-data.demo_tables.chicago_crime_sample` would be a valid table name.
* **columns** (optional): The list of columns to retrieve from the table specified in `tableName` . Useful to increase performance and optimize query costs in tables with a large number of columns. By default, all columns will be retrieved.
* **spatialDataColumn** (optional): The name of the column that contains the geospatial information (geometries/geographies) that will be used for visualization and etc. By default, CARTO assumes this column is named `geom`.
* **aggregationExp** (optional): An optional SQL expression that will define how this source will group identical geometries found in the `spatialDataColumn`. By default this property is empty and all rows will be returned. However, when this property is defined:
  * This source will return only one data point for each set of duplicated geometries
  * Each set of duplicated geometries will be aggregated using the aggregation expression defined. For example, if you have a dataset with multiple identical polygons or points and a "income" column and your`aggregationExp` is `AVG(income)` , only one polygon or point will be returned, with an income column that equals the average income of all the polygons or points identical to that one.
* **filters** (optional): A valid [CARTO Filters](/carto-for-developers/reference/filters/column-filters.md) object, used to perform server-side filtering of this data source with column-based filters.
* **filtersLogicalOperator** (optional): Indicates whether `filters` are applied following an `AND` logic or an `OR` logic.

## Response

The response of `vectorTableSource` is a promise that can be resolved and used in [layers](https://github.com/CartoDB/gitbook-documentation/blob/master/carto-for-developers/key-concepts/carto-for-deck.gl) and [widgets](/carto-for-developers/reference/carto-widgets-reference.md).

## Connection compatibility

| Connection Data Warehouse                                                      | Compatible           |
| ------------------------------------------------------------------------------ | -------------------- |
| [BigQuery](/carto-user-manual/connections/bigquery.md)                         | :white\_check\_mark: |
| [Snowflake](/carto-user-manual/connections/snowflake.md)                       | :white\_check\_mark: |
| [Redshift](/carto-user-manual/connections/redshift.md)                         | :white\_check\_mark: |
| [Databricks](/carto-user-manual/connections/databricks.md)                     | :white\_check\_mark: |
| [Oracle](/carto-user-manual/connections/oracle.md)                             | ✅                    |
| [PostgreSQL](/carto-user-manual/connections/postgresql.md)                     | :white\_check\_mark: |
| [CARTO Data Warehouse](/carto-user-manual/connections/carto-data-warehouse.md) | :white\_check\_mark: |

## Layer compatibility

`vectorTableSource` is compatible with the following layers from the `@deck.gl/carto` module:

* [VectorTileLayer](https://deck.gl/docs/api-reference/carto/vector-tile-layer)

## Widget model compatibility

`vectorTableSource` is compatible with the following widget models:

* [getFormula](/carto-for-developers/reference/carto-widgets-reference/models/getformula.md)
* [getCategories](/carto-for-developers/reference/carto-widgets-reference/models/getcategories.md)
* [getHistogram](/carto-for-developers/reference/carto-widgets-reference/models/gethistogram.md)
* [getRange](/carto-for-developers/reference/carto-widgets-reference/models/getrange.md)
* [getScatter](/carto-for-developers/reference/carto-widgets-reference/models/getscatter.md)
* [getTimeSeries](/carto-for-developers/reference/carto-widgets-reference/models/gettimeseries.md)
* [getTable](/carto-for-developers/reference/carto-widgets-reference/models/gettable.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.carto.com/carto-for-developers/reference/data-sources/vectortablesource.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
