> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-parallel-read-in-order-multi-part.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# إعدادات جلسة aggregate_*

> إعدادات جلسة ClickHouse ضمن المجموعة المُنشأة aggregate_*.

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

هذه الإعدادات متاحة في [system.settings](/ar/reference/system-tables/settings)، ويجري توليدها تلقائيًا من [المصدر](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp).

## aggregate\_function\_input\_format

<SettingsInfoBlock type="AggregateFunctionInputFormat" default_value="state" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.12"},{"label": "state"},{"label": "إعداد جديد للتحكم في صيغة إدخال AggregateFunction أثناء عمليات INSERT. تُضبط قيمة الإعداد على state افتراضيًا"}]}]} />

كيفية قراءة صيغ الإدخال للأعمدة من النوع `AggregateFunction`.

القيم الممكنة:

* `state` — الحالة المُسلسَلة للدالة التجميعية، بالشكل الذي تكتبها به تنسيقات الإخراج (القيمة الافتراضية).
* `value` — قيمة وسيطة الدالة التجميعية، أو tuple من الوسائط إن كانت متعددة. تُجمَّع القيمة لتكوين الحالة.
* `array` — مصفوفة من القيم، كما هو موضّح في الخيار `value` أعلاه. تُجمَّع جميع عناصر المصفوفة لتكوين الحالة.

في وضعَي `value` و`array` تقرأ الصيغة العمود كما لو كان من نوع القيم نفسها: `T` في حالة `AggregateFunction(f, T)`، و`Tuple(T1, T2)` في حالة `AggregateFunction(f, T1, T2)`، أو `Array` منه في وضع `array`. وتُكتب القيم بالتمثيل الذي تستخدمه الصيغة لذلك النوع: رقم أو سلسلة نصية في الصيغ النصية، ومصفوفة JSON في صيغ JSON، والترميز الثنائي للنوع في `RowBinary` أو `Native`، وعمود من ذلك النوع في `Parquet`، وهكذا. وينطبق هذا على كل صيغة إدخال، وكذلك على `AggregateFunction` المتداخل داخل `Array` أو `Tuple` أو `Map`.

**Examples**

لجدول ببنية:

```sql theme={null}
CREATE TABLE example (
    user_id UInt64,
    avg_session_length AggregateFunction(avg, UInt32)
);
```

مع `aggregate_function_input_format = 'value'`:

```sql theme={null}
INSERT INTO example FORMAT CSV
123,456
```

```sql theme={null}
INSERT INTO example FORMAT JSONEachRow
{"user_id": 123, "avg_session_length": 456}
```

مع `aggregate_function_input_format = 'array'`:

```sql theme={null}
INSERT INTO example FORMAT CSV
123,"[456,789,101]"
```

```sql theme={null}
INSERT INTO example FORMAT JSONEachRow
{"user_id": 123, "avg_session_length": [456, 789, 101]}
```

ملاحظة: صيغتا `value` و`array` أبطأ من الصيغة الافتراضية `state`، لأنهما تتطلبان إنشاء القيم وتجميعها أثناء الإدراج.

## aggregate\_functions\_null\_for\_empty

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

يُمكّن أو يعطّل إعادة كتابة جميع الدوال التجميعية في الاستعلام عبر إضافة اللاحقة [-OrNull](/ar/reference/functions/aggregate-functions/combinators#-ornull) إليها. فعِّله لتحقيق التوافق مع معيار SQL.
ويُنفَّذ ذلك من خلال إعادة كتابة الاستعلام (على غرار الإعداد [count\_distinct\_implementation](/ar/reference/settings/session-settings/count-distinct#count_distinct_implementation)) للحصول على نتائج متسقة في الاستعلامات الموزعة.

القيم الممكنة:

* 0 — معطّل.
* 1 — مفعّل.

**مثال**

انظر إلى الاستعلام التالي الذي يتضمن دوال تجميعية:

```sql theme={null}
SELECT SUM(-1), MAX(0) FROM system.one WHERE 0;
```

عند ضبط `aggregate_functions_null_for_empty = 0`، سينتج:

```text theme={null}
┌─SUM(-1)─┬─MAX(0)─┐
│       0 │      0 │
└─────────┴────────┘
```

مع `aggregate_functions_null_for_empty = 1` ستكون النتيجة كما يلي:

```text theme={null}
┌─SUMOrNull(-1)─┬─MAXOrNull(0)─┐
│          NULL │         NULL │
└───────────────┴──────────────┘
```
