> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-postgresql-tls-support.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# format_schema_* 格式设置

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

export const VersionHistory = ({rows = []}) => {
  if (rows.length === 0) {
    return null;
  }
  const headers = ["版本", "默认值", "注释"];
  const border = "1px solid rgba(128, 128, 128, 0.3)";
  const cell = {
    border,
    padding: "0.25rem 0.5rem",
    textAlign: "start",
    verticalAlign: "top"
  };
  return <details className="not-prose" style={{
    border,
    borderRadius: "0.5rem",
    margin: "0.5rem 0",
    padding: "0.5rem 0.75rem",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <summary style={{
    cursor: "pointer",
    fontWeight: 600,
    opacity: 0.72
  }}>
        版本历史
      </summary>
      <table style={{
    borderCollapse: "collapse",
    width: "100%",
    margin: "0.5rem 0 0"
  }}>
        <thead>
          <tr>
            {headers.map(header => <th key={header} style={{
    ...cell,
    fontWeight: 600,
    opacity: 0.72
  }}>
                {header}
              </th>)}
          </tr>
        </thead>
        <tbody>
          {rows.map((row, row_index) => <tr key={row.id ?? row_index}>
              {(row.items ?? []).map((item, item_index) => <td key={item_index} style={{
    ...cell,
    overflowWrap: "anywhere"
  }}>
                  {item?.label}
                </td>)}
            </tr>)}
        </tbody>
      </table>
    </details>;
};

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>;
};

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

<div id="format_schema">
  ## format\_schema
</div>

当您使用需要定义 schema 的格式 (例如 [Cap'n Proto](https://capnproto.org/) 或 [Protobuf](https://developers.google.com/protocol-buffers/)) 时，此参数会很有用。其值取决于具体格式。

<div id="format_schema_message_name">
  ## format\_schema\_message\_name
</div>

定义 `format_schema` 中指定的 schema 里所需消息的名称。
为保持与 legacy `format_schema` 格式 (`file_name:message_name`) 的兼容性：

* 如果未指定 `format_schema_message_name`，则会从 legacy `format_schema` 值中的 `message_name` 部分推断出消息名称。
* 如果在使用 legacy 格式时指定了 `format_schema_message_name`，则会引发错误。

<div id="format_schema_source">
  ## format\_schema\_source
</div>

<SettingsInfoBlock type="String" default_value="file" />

定义 `format_schema` 的来源。
可能的值：

* 'file' (默认) ：`format_schema` 是位于 `format_schemas` 目录中的 schema file 名称。
* 'string'：`format_schema` 是 schema 的字面内容。
* 'query'：`format_schema` 是一个用于获取 schema 的查询。
  当 `format_schema_source` 设置为 'query' 时，需满足以下条件：
* 查询必须恰好返回一个值：即单行单个字符串列。
* 查询结果会被视为 schema 内容。
* 该结果会缓存在本地 `format_schemas` 目录中。
* 你可以使用以下命令清除本地缓存：`SYSTEM DROP FORMAT SCHEMA CACHE FOR Files`。
* 一旦缓存，相同的查询将不会再次执行来拉取 schema，直到显式清除缓存为止
* 除了本地缓存文件外，Protobuf Message 也会缓存在内存中。即使清除了本地缓存文件，也必须使用 `SYSTEM DROP FORMAT SCHEMA CACHE [FOR Protobuf]` 清除内存缓存，才能完全刷新 schema。
* 运行查询 `SYSTEM DROP FORMAT SCHEMA CACHE`，即可一次性清除缓存文件和 Protobuf Message schema 的缓存。
