# ifNotFinite

Returns the input value if it is finite, otherwise returns the specified default value. Useful for replacing infinite or NaN values with a fallback.

## Signature

> ifNotFinite(valueToCheck, defaultValue)

| Argument       | Type   | Description                                     |
| -------------- | ------ | ----------------------------------------------- |
| `valueToCheck` | DOUBLE | Value to check for finiteness                   |
| `defaultValue` | DOUBLE | Value to return if `valueToCheck` is not finite |

Returns: **DOUBLE**

## Usage Examples

```sql
SELECT ifNotFinite(ratio, 0) AS value
FROM myTable
```

Returns `ratio` if it is finite, otherwise returns `0`.

```sql
SELECT ifNotFinite(1.0 / 0.0, -1) AS value
FROM myTable
```

| value |
| ----- |
| -1.0  |

```sql
SELECT ifNotFinite(42.5, -1) AS value
FROM myTable
```

| value |
| ----- |
| 42.5  |


---

# 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.pinot.apache.org/functions/math/ifnotfinite.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.
