> ## 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.

# schema_inference_* 格式设置

> ClickHouse 在 schema_inference_* 生成组中的格式设置。

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
  }}>类型</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>默认值</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          无需重启即可更改
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

这些设置是由 [source](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/FormatFactorySettings.h) 自动生成的。

<div id="schema_inference_hints">
  ## schema\_inference\_hints
</div>

对于没有 schema 的格式，用于在 schema 推断 中作为提示的列名和类型列表。

示例：

查询：

```sql theme={null}
desc format(JSONEachRow, '{"x" : 1, "y" : "String", "z" : "0.0.0.0" }') settings schema_inference_hints='x UInt8, z IPv4';
```

结果：

```sql theme={null}
x   UInt8
y   Nullable(String)
z   IPv4
```

<Note>
  如果 `schema_inference_hints` 格式不正确，或者包含拼写错误、错误的数据类型等问题，那么整个 schema\_inference\_hints 都会被忽略。
</Note>

<div id="schema_inference_make_columns_nullable">
  ## schema\_inference\_make\_columns\_nullable
</div>

<SettingsInfoBlock type="UInt64Auto" default_value="3" />

控制在 schema 推断 中，是否将推断出的类型设为 `Nullable`。
可选值：

* 0 - 推断出的类型绝不会是 `Nullable` (在这种情况下，使用 input\_format\_null\_as\_default 来控制如何处理 `NULL` 值) ，
* 1 - 所有推断出的类型都会是 `Nullable`，
* 2 或 `auto` - 仅当列在 schema 推断 期间解析的样本中包含 `NULL`，或者文件 metadata 包含列可空性信息时，推断出的类型才会是 `Nullable`，
* 3 - 如果该格式包含文件 metadata，则推断出的类型可空性将与其保持一致 (例如 Parquet) ；否则始终为 `Nullable` (例如 CSV) 。

<div id="schema_inference_make_json_columns_nullable">
  ## schema\_inference\_make\_json\_columns\_nullable
</div>

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

控制在 schema 推断 中将推断出的 JSON type 设为 `Nullable`。
如果此设置与 schema\_inference\_make\_columns\_nullable 同时启用，则推断出的 JSON type 将为 `Nullable`。

<div id="schema_inference_mode">
  ## schema\_inference\_mode
</div>

<SettingsInfoBlock type="SchemaInferenceMode" default_value="default" />

schema 推断模式。'default' - 假定所有文件都具有相同的 schema，并且可从任意文件推断出 schema；'union' - 文件可以具有不同的 schema，最终得到的 schema 应为所有文件 schema 的并集
