---
title: h3_polyfillash3 function
description: Learn the syntax of the h3\_polyfillash3 function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/h3_polyfillash3
---

# `h3_polyfillash3` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 11.3 LTS and above ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Lakehouse//RT

Returns an `ARRAY` of H3 cell IDs represented as `BIGINT`, corresponding to hexagons or pentagons of the specified resolution whose centroids are contained in the input areal geography.

## Syntax

```
h3_polyfillash3 ( geographyExpr, resolutionExpr )
```

## Arguments

* `geographyExpr`: A `BINARY` or `STRING` expression representing an areal geography (polygon or multipolygon) in [WKB](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry#Well-known_binary), [WKT](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry), or [GeoJSON](https://en.wikipedia.org/wiki/GeoJSON). The geography is expected to have longitude and latitude coordinates in degrees that refer to the [WGS84](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84) coordinate reference system.
* `resolutionExpr`: An `INT` expression, whose value is expected to be between `0` and `15` inclusive, specifying the resolution for the H3 cell IDs.

## Returns

An `ARRAY` of `BIGINT` values corresponding to the H3 cell IDs of the specified resolution whose centroids are contained in the input areal geography.

The function returns `NULL` if any one of the input expressions is `NULL`.
If the first input argument is of type `BINARY`, the input value is expected to be the [WKB](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry#Well-known_binary) description of a polygon or a multipolygon.
If the first input argument is of type `STRING`, the input value is expected to be either the [WKT](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) or the [GeoJSON](https://en.wikipedia.org/wiki/GeoJSON) description of a polygon or a multipolygon.
The dimension of the input polygon or multipolygon can be 2D, 3DZ, 3DM, or 4D.

## Error conditions

* If `geographyExpr` is of type `BINARY` and the value is either an invalid WKB or does not represent a polygon or multipolygon, the function returns [WKB\_PARSE\_ERROR](https://docs.databricks.com/aws/en/error-messages/wkb-parse-error-error-class.md).
* If `geographyExpr` is of type `STRING` and the value is either an invalid WKT or does not represent a polygon or multipolygon, the function returns [WKT\_PARSE\_ERROR](https://docs.databricks.com/aws/en/error-messages/wkt-parse-error-error-class.md).
* If `geographyExpr` is of type `STRING` and the value is either an invalid GeoJSON or does not represent a polygon or multipolygon, the function returns [GEOJSON\_PARSE\_ERROR](https://docs.databricks.com/aws/en/error-messages/geojson-parse-error-error-class.md).
* If `resolutionExpr` is smaller than `0` or larger than `15`, the function returns [H3\_INVALID\_RESOLUTION\_VALUE](https://docs.databricks.com/aws/en/error-messages/h3-invalid-resolution-value-error-class.md).

## Examples

```sql
-- Simple example where the input is a triangle in WKT format.
> SELECT h3_polyfillash3('POLYGON((-122.4194 37.7749,-118.2437 34.0522,-74.0060 40.7128,-122.4194 37.7749))', 2);
  [586146350232502271,586147449744130047,586198577034821631,586152397546455039,586199676546449407,586153497058082815,586142501941805055,586201325813891071]

-- Simple example where the input is a triangle in hexadecimal WKB format.
> SELECT h3_polyfillash3(unhex('0103000000010000000400000050fc1873d79a5ec0d0d556ec2fe342404182e2c7988f5dc0f46c567dae064140aaf1d24d628052c05e4bc8073d5b444050fc1873d79a5ec0d0d556ec2fe34240'), 2);
  [586146350232502271,586147449744130047,586198577034821631,586152397546455039,586199676546449407,586153497058082815,586142501941805055,586201325813891071]

-- Feeding an empty linestring in GeoJSON format (as opposed to a polygon or multipolygon).
> SELECT h3_polyfillash3('{"type":"LineString","coordinates":[]}', 2);
  [GEOJSON_PARSE_ERROR] Error parsing GeoJSON: Invalid or unsupported type '"LineString"' at position 9

-- Feeding an invalid WKB (invalid endianness value)
> SELECT h3_polyfillash3(unhex('020700000000'), 2);
  [WKB_PARSE_ERROR] Error parsing WKB: Invalid byte order 2 at position 1

-- Feeding an invalid polygon in WKT (polygon is not closed)
> SELECT h3_polyfillash3('POLYGON((-122.4194 37.7749,-118.2437 34.0522,-74.0060 40.7128,-74.0060 40.7128))', 2);
  [WKT_PARSE_ERROR] Error parsing WKT: Found non-closed ring at position 80

-- Resolution is out of range.
> SELECT h3_polyfillash3('POLYGON((-122.4194 37.7749,-118.2437 34.0522,-74.0060 40.7128,-122.4194 37.7749))', 16);
  [H3_INVALID_RESOLUTION_VALUE] H3 resolution 16 must be between 0 and 15, inclusive
```

## Related functions

* [`h3_coverash3` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/h3_coverash3.md)
* [`h3_coverash3string` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/h3_coverash3string.md)
* [`h3_polyfillash3string` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/h3_polyfillash3string.md)
* [`h3_tessellateaswkb` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/h3_tessellateaswkb.md)
* [`h3_try_coverash3` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/h3_try_coverash3.md)
* [`h3_try_coverash3string` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/h3_try_coverash3string.md)
* [`h3_try_polyfillash3` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/h3_try_polyfillash3.md)
* [`h3_try_polyfillash3string` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/h3_try_polyfillash3string.md)
* [`h3_try_tessellateaswkb` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/h3_try_tessellateaswkb.md)
