> For the complete documentation index, see [llms.txt](https://docs.pinot.apache.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pinot.apache.org/release-1.0.0/configuration-reference/functions/stpolygon.md).

# ST\_Polygon

This section contains reference documentation for the ST\_Polygon function.

Returns a geometry type polygon object from [Well-Known Text representation or extended (WKT)](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry).

{% hint style="info" %}
This function only works for WKT formatted polygons.
{% endhint %}

## Signature

> ST\_Polygon(wkt)

## Usage Examples

These examples are based on the [Streaming Quick Start](/release-1.0.0/basics/getting-started/quick-start.md#streaming).

```sql
select ST_Polygon('POLYGON ((2 2, 2 6, 6 6, 6 2, 2 2))') AS value
from meetupRsvp 
LIMIT 1
```

| value                                                                                                                                                                                      |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 040000000100000005000000004000000000000000400000000000000040000000000000004018000000000000401800000000000040180000000000004018000000000000400000000000000040000000000000004000000000000000 |

```sql
select ST_Polygon('POLYGON EMPTY') AS value
from meetupRsvp 
LIMIT 1
```

| value              |
| ------------------ |
| 040000000000000000 |

This function doesn't accept values that represent non polygons. It will throw an exception if passed other primitives or geometries:

```sql
select ST_Polygon('LINESTRING (30 10, 10 30, 40 40)') AS value
from meetupRsvp 
LIMIT 1
```

```
[
  {
    "message": "QueryExecutionError:\njava.lang.IllegalArgumentException: The geometry object must be polygon\n\tat shaded.com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)\n\tat org.apache.pinot.core.geospatial.transform.function.StPolygonFunction.transformToBytesValuesSV(StPolygonFunction.java:58)\n\tat org.apache.pinot.core.operator.docvalsets.TransformBlockValSet.getBytesValuesSV(TransformBlockValSet.java:95)\n\tat org.apache.pinot.core.common.RowBasedBlockValueFetcher.createFetcher(RowBasedBlockValueFetcher.java:66)",
    "errorCode": 200
  }
]
```

To create geometry objects for non polygons, see [ST\_GeomFromText](/release-1.0.0/configuration-reference/functions/stgeomfromtext.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pinot.apache.org/release-1.0.0/configuration-reference/functions/stpolygon.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
