> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.firebolt.io/feedback

```json
{
  "path": "/reference-sql/functions-reference/numeric/array-enumerate",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

> Reference material for ARRAY_ENUMERATE function

# ARRAY_ENUMERATE

export const QueryWindow = ({content}) => {
  const {sql, result} = content;
  const [inited, setInited] = useState(false);
  const buttonRef = useRef(null);
  useEffect(() => {
    if (!inited && buttonRef.current) {
      runQuery(buttonRef.current, true);
      setInited(true);
    }
  }, []);
  return <div className="query-window">
      <div className="query-toolbar">
        <button className="run-button" onClick={ev => runQuery(ev.target)} ref={buttonRef}>Run Query</button>
        <span className="window-title">Interactive SQL Playground 🔥</span>
      </div>
      <div className="query-content">
        <pre><code className="firebolt-sql language-sql" contentEditable="true" spellCheck="false" data-original-query={sql}>{sql}</code></pre>
        <script type="application/json" className="fallback-result" style={{
    display: "none"
  }}>{JSON.stringify(result)}</script>
        <div className="server-unavailable-banner query-window-hidden">
          The Firebolt playground server is currently unavailable. Using precomputed query results.
        </div>
        <div className="query-results"></div>
      </div>
    </div>;
};

This function takes an array of arbitrary type as input, and produces an integer array of the same length containing increasing numbers.
The returned array starts with value one. Every successive element is incremented by one, it holds that `array[i] = array[i - 1] + 1`.

`NULLs` contained in the parameter array are treated like any other value, and result in a non-null element in the returned array.

If the parameter array is `NULL`, then the function also returns `NULL`.

## Syntax

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
ARRAY_ENUMERATE(<array>)
```

## Parameters

| Parameter | Description                                                                                                    | Supported input types |
| :-------- | :------------------------------------------------------------------------------------------------------------- | :-------------------- |
| `<array>` | The array to be enumerated. The length of the returned array is the same as the length of the parameter array. | Any array type.       |

## Return Type

`ARRAY(INT)`

## Example

The following example returns an array with values one to four:

<QueryWindow
  content={{
"sql": "SELECT ARRAY_ENUMERATE([7, 9, 3, 4]) AS one_to_four;",
"result": {
"data": [
  [
    [
      1,
      2,
      3,
      4
    ]
  ]
],
"meta": [
  {
    "name": "one_to_four",
    "type": "array(int)"
  }
],
"query": {
  "query_id": "31247b64-c8da-4188-9f07-d302ab6d3519",
  "query_label": null,
  "request_id": "6fd5e5d3-ed92-420b-85ec-1714ef7f2706"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.006495,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000253728,
  "time_to_execute": 9.0131e-05
}
}
}}
/>

The array passed to the function can contain arbitrary types:

<QueryWindow
  content={{
"sql": "SELECT ARRAY_ENUMERATE(['hello', 'world']) AS one_to_two;",
"result": {
"data": [
  [
    [
      1,
      2
    ]
  ]
],
"meta": [
  {
    "name": "one_to_two",
    "type": "array(int)"
  }
],
"query": {
  "query_id": "3e2bff34-b7b9-4a61-a010-f24c17462c48",
  "query_label": null,
  "request_id": "03079b47-53c2-48c7-a85d-2cf24a104086"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.007034,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000263834,
  "time_to_execute": 9.9254e-05
}
}
}}
/>

NULL values are still reflected in the returned result:

<QueryWindow
  content={{
"sql": "SELECT ARRAY_ENUMERATE([7, NULL, 3, NULL]) AS one_to_four;",
"result": {
"data": [
  [
    [
      1,
      2,
      3,
      4
    ]
  ]
],
"meta": [
  {
    "name": "one_to_four",
    "type": "array(int)"
  }
],
"query": {
  "query_id": "053a8607-aa25-4241-a4c6-7d822a9dc773",
  "query_label": null,
  "request_id": "85519ef2-9a4b-4cf3-af12-bf0376fe409e"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.00707,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000264469,
  "time_to_execute": 0.000103436
}
}
}}
/>

If the array passed to the function is NULL, so is the result:

<QueryWindow
  content={{
"sql": "SELECT ARRAY_ENUMERATE(NULL) AS null_result;",
"result": {
"data": [
  [
    null
  ]
],
"meta": [
  {
    "name": "null_result",
    "type": "array(int) null"
  }
],
"query": {
  "query_id": "da9d5cb0-41e7-421f-ad33-37c617e4dd3e",
  "query_label": null,
  "request_id": "d6b54ef2-5d12-41bf-8b7a-75df413b605e"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.006803,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000258874,
  "time_to_execute": 9.9907e-05
}
}
}}
/>
