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

# allow_* 会话设置

> ClickHouse 中 allow_* 生成组下的会话设置。

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

export const BetaBadge = ({link, galaxyTrack, galaxyEvent}) => {
  if (link) {
    return <a href={link} target="_blank" rel="noopener noreferrer" className="betaBadge" onClick={galaxyTrack && galaxyEvent ? galaxyOnClick(galaxyEvent) : undefined}>
                <Icon />
                <span>Beta</span>
            </a>;
  }
  return <div className="betaBadge">
            <Icon />
            <span>
                Beta 版功能。 
                <u>
                    <a href="/docs/docs/beta-and-experimental-features#beta-features">
                        了解更多。
                    </a>
                </u>
            </span>
        </div>;
};

export const ExperimentalBadge = () => {
  return <div className="experimentalBadge">
            <div className="experimentalIcon">
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path strokeWidth="1.25" d="M5.5 2H10.5" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
                <path strokeWidth="1.25" d="M9.50015 2V6.19625L13.4283 12.7425C13.4738 12.8183 13.4985 12.9049 13.4996 12.9934C13.5008 13.0818 13.4785 13.169 13.435 13.246C13.3914 13.323 13.3283 13.3871 13.2519 13.4317C13.1755 13.4764 13.0886 13.4999 13.0002 13.5H3.00015C2.91164 13.5 2.8247 13.4766 2.74822 13.432C2.67174 13.3874 2.60847 13.3233 2.56487 13.2463C2.52126 13.1693 2.49889 13.082 2.50004 12.9935C2.50119 12.905 2.52582 12.8184 2.5714 12.7425L6.50015 6.19625V2" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
                <path strokeWidth="1.25" d="M4.47656 9.56754C5.30344 9.41254 6.47656 9.47942 7.99969 10.25C10.0153 11.2707 11.4216 11.0569 12.2184 10.7282" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
            </svg>
        </div>
            Experimental 功能。 <u><a href="/docs/docs/beta-and-experimental-features#experimental-features">了解详情。</a></u>
        </div>;
};

这些设置可在 [system.settings](/docs/zh/reference/system-tables/settings) 中查看，并由 [源码](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp) 自动生成。

<div id="allow_aggregate_partitions_independently">
  ## allow\_aggregate\_partitions\_independently
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.7"},{"label": "1"},{"label": "当分区键适合 GROUP BY 键时，默认启用按分区独立聚合。`ReadFromMergeTree::requestOutputEachPartitionThroughSeparatePortForAggregation` 中现有的运行时启发式规则会在分区布局不理想时（分区过少、分区过多，或分区大小严重失衡）跳过此优化，因此在原本只会成为空操作的情况下，启用该设置也是安全的。"}]}]} />

当分区键适合 GROUP BY 键时，启用在独立线程上对各分区分别进行聚合。当分区数量接近 CPU 核心数，且各分区大小大致相同时，此功能最有利。`ReadFromMergeTree` 中的启发式规则会在布局不理想时 (分区过少、分区过多，或分区大小严重失衡) 自动禁用该优化；如需绕过这些检查，请参见 `force_aggregate_partitions_independently`。

<div id="allow_archive_path_syntax">
  ## allow\_archive\_path\_syntax
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.8"},{"label": "1"},{"label": "新增设置，可禁用归档路径语法。"}]}, {"id": "row-2","items": [{"label": "24.5"},{"label": "1"},{"label": "新增设置，可禁用归档路径语法。"}]}]} />

File/S3 引擎/表函数会将包含 '::' 的路径解析为 `<archive> :: <file>`，前提是归档文件具有正确的扩展名。

<div id="allow_asynchronous_read_from_io_pool_for_merge_tree">
  ## allow\_asynchronous\_read\_from\_io\_pool\_for\_merge\_tree
</div>

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

使用后台 I/O 线程池从 MergeTree 表中读取数据。此设置可能会提高受 I/O 限制的查询的性能

<div id="allow_calculating_subcolumns_sizes_for_merge_tree_reading">
  ## allow\_calculating\_subcolumns\_sizes\_for\_merge\_tree\_reading
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.3"},{"label": "1"},{"label": "允许在读取 MergeTree 时计算子列大小，以优化读取任务拆分"}]}]} />

启用后，ClickHouse 将计算读取每个子列所需文件的大小，以便更准确地计算任务大小和块大小。

<div id="allow_changing_replica_until_first_data_packet">
  ## allow\_changing\_replica\_until\_first\_data\_packet
</div>

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

如果启用，在对冲请求中，即使已经有了一些进度，也可以在收到第一个数据包之前发起新的连接
(但在 `receive_data_timeout` 超时时间内进度没有更新) ；否则，一旦首次取得进度，就会禁止切换副本。

<div id="allow_create_index_without_type">
  ## allow\_create\_index\_without\_type
</div>

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

允许执行不带 TYPE 的 CREATE INDEX 查询。该查询会被忽略。此设置用于 SQL 兼容性测试。

<div id="allow_custom_error_code_in_throwif">
  ## allow\_custom\_error\_code\_in\_throwif
</div>

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

在 throwIf() 函数中启用自定义错误代码。如果为 true，抛出的异常可能带有非预期的错误代码。

<div id="allow_ddl">
  ## allow\_ddl
</div>

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

如果设置为 true，则用户可以执行 DDL 查询。

<div id="allow_distributed_ddl">
  ## allow\_distributed\_ddl
</div>

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

如果设置为 true，则允许用户执行分布式 DDL 查询。

<div id="allow_drop_detached">
  ## allow\_drop\_detached
</div>

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

允许执行 ALTER TABLE ... DROP DETACHED PART\[ITION] ... 语句

<div id="allow_dynamic_type_in_join_keys">
  ## allow\_dynamic\_type\_in\_join\_keys
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.10"},{"label": "0"},{"label": "默认禁止在 JOIN 连接键中使用 Dynamic 类型"}]}]} />

允许在 JOIN 连接键中使用 Dynamic 类型。此设置是为兼容性而添加的。不建议在 JOIN 连接键中使用 Dynamic 类型，因为与其他类型比较时可能会产生意外结果。

<div id="allow_execute_multiif_columnar">
  ## allow\_execute\_multiif\_columnar
</div>

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

允许以列式方式执行 multiIf 函数

<div id="allow_fuzz_query_functions">
  ## allow\_fuzz\_query\_functions
</div>

<ExperimentalBadge />

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.2"},{"label": "0"},{"label": "用于启用 fuzzQuery 函数的新设置。"}]}]} />

启用 `fuzzQuery` 函数，该函数会对查询字符串进行随机 AST 变更。

<div id="allow_general_join_planning">
  ## allow\_general\_join\_planning
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.1"},{"label": "1"},{"label": "在启用 hash join 算法时，允许使用更通用的 JOIN 规划算法。"}]}]} />

允许使用一种更通用的 JOIN 规划算法，可处理更复杂的条件，但仅适用于 hash join。如果未启用 hash join，则无论此设置的值如何，都会使用常规的 JOIN 规划算法。

<div id="allow_get_client_http_header">
  ## allow\_get\_client\_http\_header
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.3"},{"label": "0"},{"label": "新增了一个函数。"}]}]} />

允许使用函数 `getClientHTTPHeader`，该函数可用于获取当前 HTTP 请求的请求头值。出于安全考虑，此功能默认未启用，因为某些请求头 (如 `Cookie`) 可能包含敏感信息。请注意，`X-ClickHouse-*`、`Authentication` 和 `Authorization` 请求头始终受限，无法通过此函数获取。

<div id="allow_hyperscan">
  ## allow\_hyperscan
</div>

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

允许使用 Hyperscan 库的函数。禁用此设置可避免潜在的编译时间过长以及资源占用过高。

<div id="allow_iceberg_remove_orphan_files">
  ## allow\_iceberg\_remove\_orphan\_files
</div>

<ExperimentalBadge />

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.4"},{"label": "0"},{"label": "用于控制 Iceberg 孤立文件删除的新设置"}]}]} />

允许对 Iceberg 表执行 'ALTER TABLE ... EXECUTE remove\_orphan\_files()'。

<div id="allow_insert_into_iceberg">
  ## allow\_insert\_into\_iceberg
</div>

<BetaBadge />

**别名**: `allow_experimental_insert_into_iceberg`

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.2"},{"label": "0"},{"label": "向 Iceberg 插入已调整为 Beta"}]}, {"id": "row-2","items": [{"label": "25.7"},{"label": "0"},{"label": "新设置。"}]}]} />

允许执行向 Iceberg 插入数据的 `insert` 查询。

<div id="allow_introspection_functions">
  ## allow\_introspection\_functions
</div>

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

启用或禁用用于查询性能分析的[内部信息函数](/docs/zh/reference/functions/regular-functions/introspection)。

可选值：

* 1 — 启用内部信息函数。
* 0 — 禁用内部信息函数。

**另请参阅**

* [采样查询分析器](/docs/zh/concepts/features/performance/troubleshoot/sampling-query-profiler)
* 系统表 [trace\_log](/docs/zh/reference/system-tables/trace_log)

<div id="allow_key_condition_coalesce_rewrite">
  ## allow\_key\_condition\_coalesce\_rewrite
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.5"},{"label": "1"},{"label": "新增设置：在索引分析之前，将形如 `coalesce(a_1, ..., a_N) <op> const` 的谓词（以及等价的 `ifNull` 形式，或常量在左侧的情况）重写为析取形式，从而可以使用每个 `a_i` 上的按列主键和跳过索引。还支持部分常量形式，例如 `coalesce(a, 42, b)` 和 `coalesce(a, b, 42)`。"}]}]} />

允许 MergeTree 主键和跳过索引对涉及 `coalesce` 或 `ifNull` 的 `WHERE`/`PREWHERE` 谓词裁剪粒度。若不启用此设置，这类谓词对索引分析是透明的，无法进行裁剪，因此即使某些粒度不可能匹配，仍然会被读取。该设置只影响读取哪些粒度；查询结果不会改变，因为行仍会按原始谓词进行过滤。

在索引分析之前，会重写两种谓词形态：

* 将针对 `coalesce`/`ifNull` 的比较 (例如 `coalesce(a, b) = 5`) 改写为析取形式，以便每个参数上的索引都能参与裁剪：`a = 5 OR (a IS NULL AND b = 5)`，参数更多时也会按此方式扩展。
* 将带有假值 (零) 常量默认值且直接用作条件的 `coalesce`/`ifNull` (例如 `ifNull(a = 5, 0)` 或 `coalesce(a = 5, 0)`) 解包为其内部谓词 `a = 5`。这类包装会将内部谓词的三值结果收敛为确定的布尔值 (即将 `NULL` 映射为 `false`) 。

<div id="allow_limit_by_partitions_independently">
  ## allow\_limit\_by\_partitions\_independently
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.6"},{"label": "1"},{"label": "新增设置：当分区表达式是 `LIMIT BY` 列的确定性函数时，启用按分区独立计算 `LIMIT BY`。"}]}]} />

当分区表达式是 `LIMIT BY` 列的确定性函数时，启用在独立线程中按分区分别计算 `LIMIT BY`。

<div id="allow_materialized_view_with_bad_select">
  ## allow\_materialized\_view\_with\_bad\_select
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.4"},{"label": "0"},{"label": "不允许创建引用不存在列或表的 MV"}]}, {"id": "row-2","items": [{"label": "24.9"},{"label": "1"},{"label": "支持（但尚未启用）在 CREATE MATERIALIZED VIEW 中进行更严格的验证"}]}]} />

允许 CREATE MATERIALIZED VIEW 使用引用不存在表或列的 SELECT 查询。但该查询在语法上仍必须有效。不适用于 refreshable MV。如果 MV 的 schema 需要从 SELECT 查询中推断，也不适用 (即 CREATE 没有列列表，且没有 TO table) 。可用于在源表创建之前先创建 MV。

<div id="allow_minmax_index_for_json">
  ## allow\_minmax\_index\_for\_json
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.7"},{"label": "0"},{"label": "默认禁止在 JSON 列上创建 minmax 跳过索引，因为索引序列化无法处理不同类型的 Field 值"}]}]} />

允许在 JSON (Object) 列上创建 minmax 跳过索引。默认处于禁用状态，因为 minmax
索引的序列化过程无法处理 JSON 列中可能包含的不同类型的 Field 值。

<div id="allow_named_collection_override_by_default">
  ## allow\_named\_collection\_override\_by\_default
</div>

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

默认允许覆盖命名集合中的字段。

<div id="allow_non_metadata_alters">
  ## allow\_non\_metadata\_alters
</div>

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

允许执行不仅会影响表元数据，还会影响磁盘上数据的 alter 操作

<div id="allow_nonconst_timezone_arguments">
  ## allow\_nonconst\_timezone\_arguments
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "23.4"},{"label": "0"},{"label": "允许在某些与时间相关的函数中使用非常量时区参数，例如 toTimeZone()、fromUnixTimestamp*() 和 snowflakeToDateTime*()。"}]}]} />

允许在某些与时间相关的函数中使用非常量时区参数，例如 toTimeZone()、fromUnixTimestamp\*() 和 snowflakeIDToDateTime\*()。
此设置仅为兼容性而保留。在 ClickHouse 中，时区是数据类型的属性，也就是列的属性。
启用此设置会给人一种错误的印象，仿佛同一列中的不同值可以具有不同的时区。
因此，请不要启用此设置。

<div id="allow_nullable_tuple_in_extracted_subcolumns">
  ## allow\_nullable\_tuple\_in\_extracted\_subcolumns
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.3"},{"label": "0"},{"label": "用于控制提取的 Tuple 子列是否可以为可空类型的新设置。"}]}]} />

控制类型为 `Tuple(...)` 的提取子列是否可以设为 `Nullable(Tuple(...))` 类型。

* `false`：返回 `Tuple(...)`，并对缺少该子列的行使用默认 Tuple 值。
* `true`：返回 `Nullable(Tuple(...))`，并对缺少该子列的行使用 `NULL`。

此设置仅控制提取子列的行为。
它不控制是否可以在表中创建 `Nullable(Tuple(...))` 列；这一点由 `enable_nullable_tuple_type` 控制。

ClickHouse 使用服务器启动时加载的此设置值。
通过 `SET` 或查询级 `SETTINGS` 所做的更改不会改变提取子列的行为。
要更改提取子列的行为，请在启动 profile 配置 (例如 users.xml) 中更新 `allow_nullable_tuple_in_extracted_subcolumns`，然后重启服务器。

<div id="allow_rank_dense_rank_arguments">
  ## allow\_rank\_dense\_rank\_arguments
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.5"},{"label": "0"},{"label": "新设置。在 26.5 之前，`RANK` 和 `DENSE_RANK` 窗口函数会静默忽略任何传入参数（等同于 `allow_rank_dense_rank_arguments = 1`）。从 26.5 开始，它们默认会因 `NUMBER_OF_ARGUMENTS_DOESNT_MATCH` 而拒绝参数，因为根据 SQL 标准，这些函数不接受任何参数。将此项设为 `1` 可恢复旧版行为。"}]}]} />

允许向 `RANK` 和 `DENSE_RANK` 窗口函数传递参数，以保持向后兼容。

根据 SQL 标准，`RANK` 和 `DENSE_RANK` 不接受任何参数——它们仅根据
`OVER (ORDER BY ...)` 窗口对行进行排名。在 26.5 之前的 ClickHouse 版本中，类似
`RANK(x) OVER (...)` 的查询会静默接受并忽略该参数，这会导致用户困惑
(显式写出的参数看起来似乎会影响排名，但实际上并不会) 。

当此设置为 `false` (默认值) 时，`RANK` 和 `DENSE_RANK` 会拒绝任何参数，并
抛出 `NUMBER_OF_ARGUMENTS_DOESNT_MATCH`。当设为 `true` 时，将恢复旧版的宽松行为——
参数会被静默忽略，与 26.5 之前的行为一致。

<div id="allow_reorder_prewhere_conditions">
  ## allow\_reorder\_prewhere\_conditions
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.10"},{"label": "1"},{"label": "新设置"}]}]} />

将条件从 WHERE 移至 PREWHERE 时，允许重新排序这些条件，以优化筛选

<div id="allow_replace_partition_from_empty_source">
  ## allow\_replace\_partition\_from\_empty\_source
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.6"},{"label": "0"},{"label": "新增安全检查：如果源表在请求的分区中没有 parts，`ALTER TABLE ... REPLACE PARTITION ... FROM ...` 现在会抛出异常（修复了 [#23727](https:\/\/github.com\/ClickHouse\/ClickHouse\/issues\/23727) 中静默数据丢失的问题）。将 `allow_replace_partition_from_empty_source = 1` 可保留之前的行为，即静默删除目标端分区。"}]}]} />

允许在源表对应分区中没有 parts 时，`ALTER TABLE ... REPLACE PARTITION ... FROM ...` 静默删除目标端分区。

默认情况下不允许这样做：如果源表在请求的分区中没有数据，那么从该源执行 `REPLACE PARTITION` 会抛出异常，因为这种情况下，该操作实际上等同于对目标端静默执行 `DROP PARTITION` (目标端数据会被删除，但不会有任何内容替换它) ，这也是意外数据丢失的常见原因 (参见 [#23727](https://github.com/ClickHouse/ClickHouse/issues/23727)) 。

启用此设置可恢复之前的行为，例如当你有意使用空源分区来清空目标端数据时。若要无条件删除，建议直接改用 `ALTER TABLE ... DROP PARTITION ...`。

<div id="allow_settings_after_format_in_insert">
  ## allow\_settings\_after\_format\_in\_insert
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "22.4"},{"label": "0"},{"label": "不允许在 `INSERT` 查询中于 `FORMAT` 之后使用 `SETTINGS`，因为 ClickHouse 会将 `SETTINGS` 解释为某些值，容易造成误解"}]}]} />

控制是否允许在 `INSERT` 查询中于 `FORMAT` 之后使用 `SETTINGS`。不建议使用此设置，因为这可能会将 `SETTINGS` 的一部分解释为值。

示例：

```sql theme={null}
INSERT INTO FUNCTION null('foo String') SETTINGS max_threads=1 VALUES ('bar');
```

但以下查询只有在启用 `allow_settings_after_format_in_insert` 时才能运行：

```sql theme={null}
SET allow_settings_after_format_in_insert=1;
INSERT INTO FUNCTION null('foo String') VALUES ('bar') SETTINGS max_threads=1;
```

可能的值：

* 0 — 禁止。
* 1 — 允许。

<Note>
  仅当你的用例依赖旧语法、需要保持向后兼容时，才使用此设置。
</Note>

<div id="allow_simdjson">
  ## allow\_simdjson
</div>

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

如果支持 AVX2 指令，则允许在 `JSON*` 函数中使用 simdjson 库。禁用后将使用 rapidjson。

<div id="allow_special_serialization_kinds_in_output_formats">
  ## allow\_special\_serialization\_kinds\_in\_output\_formats
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.11"},{"label": "1"},{"label": "在某些输出格式中启用直接输出 Sparse/Replicated 等特殊列表示"}]}, {"id": "row-2","items": [{"label": "25.10"},{"label": "0"},{"label": "新增一个设置，允许输出 Sparse/Replicated 等特殊列表示，而不将其转换为普通列"}]}]} />

允许直接输出具有 Sparse 和 Replicated 等特殊序列化类型的列，而无需将其转换为普通列表示。
这有助于避免格式化过程中不必要的数据复制。

<div id="allow_unrestricted_reads_from_keeper">
  ## allow\_unrestricted\_reads\_from\_keeper
</div>

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

允许从 system.zookeeper 表进行不受限制的读取 (即不对 path 作条件限制) 。这可能会比较方便，但对 ZooKeeper 来说并不安全
