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

# configurações de sessão cast_*

> Configurações de sessão do ClickHouse no grupo gerado cast_*.

export const SettingsInfoBlock = ({type, default_value, changeable_without_restart}) => {
  return <div className="not-prose" style={{
    display: "flex",
    flexWrap: "wrap",
    alignItems: "baseline",
    columnGap: "0.5rem",
    rowGap: "0.125rem",
    margin: "0.375rem 0",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <div style={{
    fontWeight: 600,
    opacity: 0.72
  }}>Tipo</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>Padrão</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          Pode ser alterado sem reiniciar
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

Essas configurações estão disponíveis em [system.settings](/docs/pt-BR/reference/system-tables/settings) e são geradas automaticamente a partir do [código-fonte](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp).

<div id="cast_ipv4_ipv6_default_on_conversion_error">
  ## cast\_ipv4\_ipv6\_default\_on\_conversion\_error
</div>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "22.3"},{"label": "0"},{"label": "Faz com que as funções cast(value, 'IPv4') e cast(value, 'IPv6') se comportem da mesma forma que as funções toIPv4 e toIPv6"}]}]} />

O operador CAST para IPv4, o operador CAST para o tipo IPv6 e as funções toIPv4 e toIPv6 retornarão o valor padrão em vez de gerar uma exceção em caso de erro de conversão.

<div id="cast_keep_nullable">
  ## cast\_keep\_nullable
</div>

<SettingsInfoBlock type="Bool" default_value="0" />

Habilita ou desabilita a preservação do tipo de dado `Nullable` em operações [CAST](/docs/pt-BR/reference/functions/regular-functions/type-conversion-functions#CAST).

Quando essa configuração está habilitada e o argumento da função `CAST` é `Nullable`, o resultado também é convertido para o tipo `Nullable`. Quando a configuração está desabilitada, o resultado sempre tem exatamente o tipo de destino.

Valores possíveis:

* 0 — O resultado de `CAST` tem exatamente o tipo de destino especificado.
* 1 — Se o tipo do argumento for `Nullable`, o resultado de `CAST` é convertido para `Nullable(DestinationDataType)`.

**Exemplos**

A consulta a seguir resulta exatamente no tipo de dado de destino:

```sql theme={null}
SET cast_keep_nullable = 0;
SELECT CAST(toNullable(toInt32(0)) AS Int32) as x, toTypeName(x);
```

Resultado:

```text theme={null}
┌─x─┬─toTypeName(CAST(toNullable(toInt32(0)), 'Int32'))─┐
│ 0 │ Int32                                             │
└───┴───────────────────────────────────────────────────┘
```

A consulta a seguir resulta na modificação `Nullable` do tipo de dados de destino:

```sql theme={null}
SET cast_keep_nullable = 1;
SELECT CAST(toNullable(toInt32(0)) AS Int32) as x, toTypeName(x);
```

Resultado:

```text theme={null}
┌─x─┬─toTypeName(CAST(toNullable(toInt32(0)), 'Int32'))─┐
│ 0 │ Nullable(Int32)                                   │
└───┴───────────────────────────────────────────────────┘
```

**Veja também**

* [CAST](/docs/pt-BR/reference/functions/regular-functions/type-conversion-functions#CAST) função
