I created a constraint to limit the string size, which could be inserted into ClickHouse.
When the constraint is violated, the full rejected string is recorded in the exception message in the query log.
play-eu :) SELECT length(exception), substring(exception, 1, 1000) FROM system.query_views_log WHERE length(exception) > 1000000 ORDER BY event_time DESC LIMIT 5
SELECT
length(exception),
substring(exception, 1, 1000)
FROM system.query_views_log
WHERE length(exception) > 1000000
ORDER BY event_time DESC
LIMIT 5
Query id: f69eb5ee-5e0f-48b5-8a11-e239cc70dcf8
┌─length(exception)─┬─substring(exception, 1, 1000)──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
1. │ 100322500 │ Code: 469. DB::Exception: Constraint `length` for table sink.data (e54970cf-7b35-4ac8-bf97-d7e1273685c1) is violated at row 1. Expression: (length(content) < (1024 * 1024)). Column values: content = 'System name: Spark (Auron)\nProprietary: no\nTuned: no\nTags: ["Java","Rust","column-oriented","Spark derivative"]\nDisk usage before: 2128011264\nHit:1 http://eu-central-1b.clouds.ports.ubuntu.com/ubuntu-ports noble InRelease\nHit:2 http://eu-central-1b.clouds.ports.ubuntu.com/ubuntu-ports noble-updates InRelease\nHit:3 http://eu-central-1b.clouds.ports.ubuntu.com/ubuntu-ports noble-backports InRelease\nHit:4 http://ports.ubuntu.com/ubuntu-ports noble-security InRelease\nReading package lists...\nReading package lists...\nBuilding dependency tree...\nReading state information...\nThe following additional packages will be installed:\n adwaita-icon-theme alsa-topology-conf alsa-ucm-conf at-spi2-common\n at-spi2-core binutils binutils-aarch64-linux-gnu binutils-common\n build-essential bz │
2. │ 75754744 │ Code: 469. DB::Exception: Constraint `length` for table sink.data (e54970cf-7b35-4ac8-bf97-d7e1273685c1) is violated at row 1. Expression: (length(content) < (1024 * 1024)). Column values: content = 'Cloud-init v. 25.1.4-0ubuntu0~24.04.1 running \'init-local\' at Thu, 11 Sep 2025 18:59:56 +0000. Up 5.02 seconds.\nCloud-init v. 25.1.4-0ubuntu0~24.04.1 running \'init\' at Thu, 11 Sep 2025 19:00:01 +0000. Up 9.29 seconds.\nci-info: ++++++++++++++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++++++++++++\nci-info: +--------+------+----------------------------+---------------+--------+-------------------+\nci-info: | Device | Up | Address | Mask | Scope | Hw-Address |\nci-info: +--------+------+----------------------------+---------------+--------+-------------------+\nci-info: | ens5 | True | 172.31.1.245 | 255.255.240.0 | global | 0a:24:0f:bd:8d:6b |\nci-info: | ens5 | True | fe80::824:fff:febd:8d6b/64 | . │
3. │ 55767538 │ Code: 469. DB::Exception: Constraint `length` for table sink.data (e54970cf-7b35-4ac8-bf97-d7e1273685c1) is violated at row 1. Expression: (length(content) < (1024 * 1024)). Column values: content = 'System name: Spark (Auron)\nProprietary: no\nTuned: no\nTags: ["Java","Rust","column-oriented","Spark derivative"]\nDisk usage before: 2109595648\nHit:1 http://eu-central-1.ec2.archive.ubuntu.com/ubuntu noble InRelease\nHit:2 http://eu-central-1.ec2.archive.ubuntu.com/ubuntu noble-updates InRelease\nHit:3 http://eu-central-1.ec2.archive.ubuntu.com/ubuntu noble-backports InRelease\nHit:4 http://security.ubuntu.com/ubuntu noble-security InRelease\nReading package lists...\nReading package lists...\nBuilding dependency tree...\nReading state information...\nThe following additional packages will be installed:\n adwaita-icon-theme alsa-topology-conf alsa-ucm-conf at-spi2-common\n at-spi2-core binutils binutils-common binutils-x86-64-linux-gnu\n build-essential bzip2 ca-certificates-java cpp │
4. │ 75938694 │ Code: 469. DB::Exception: Constraint `length` for table sink.data (e54970cf-7b35-4ac8-bf97-d7e1273685c1) is violated at row 1. Expression: (length(content) < (1024 * 1024)). Column values: content = 'Cloud-init v. 25.1.4-0ubuntu0~24.04.1 running \'init-local\' at Thu, 11 Sep 2025 18:59:53 +0000. Up 5.45 seconds.\nCloud-init v. 25.1.4-0ubuntu0~24.04.1 running \'init\' at Thu, 11 Sep 2025 18:59:56 +0000. Up 8.41 seconds.\nci-info: ++++++++++++++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++++++++++++++\nci-info: +--------+------+-----------------------------+---------------+--------+-------------------+\nci-info: | Device | Up | Address | Mask | Scope | Hw-Address |\nci-info: +--------+------+-----------------------------+---------------+--------+-------------------+\nci-info: | ens5 | True | 172.31.9.37 | 255.255.240.0 | global | 0a:17:a5:10:1c:d5 |\nci-info: | ens5 | True | fe80::817:a5ff:fe10:1cd5/64 | │
5. │ 56135058 │ Code: 469. DB::Exception: Constraint `length` for table sink.data (e54970cf-7b35-4ac8-bf97-d7e1273685c1) is violated at row 1. Expression: (length(content) < (1024 * 1024)). Column values: content = 'System name: Spark (Auron)\nProprietary: no\nTuned: no\nTags: ["Java","Rust","column-oriented","Spark derivative"]\nDisk usage before: 2105778176\nHit:1 http://eu-central-1.ec2.archive.ubuntu.com/ubuntu noble InRelease\nHit:2 http://eu-central-1.ec2.archive.ubuntu.com/ubuntu noble-updates InRelease\nHit:3 http://eu-central-1.ec2.archive.ubuntu.com/ubuntu noble-backports InRelease\nHit:4 http://security.ubuntu.com/ubuntu noble-security InRelease\nReading package lists...\nReading package lists...\nBuilding dependency tree...\nReading state information...\nThe following additional packages will be installed:\n adwaita-icon-theme alsa-topology-conf alsa-ucm-conf at-spi2-common\n at-spi2-core binutils binutils-common binutils-x86-64-linux-gnu\n build-essential bzip2 ca-certificates-java cpp │
└───────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
5 rows in set. Elapsed: 0.808 sec. Processed 2.16 million rows, 1.11 GB (2.67 million rows/s., 1.37 GB/s.)
Peak memory usage: 2.44 GiB.
Company or project name
ClickHouse
Describe the unexpected behaviour
I created a constraint to limit the string size, which could be inserted into ClickHouse.
When the constraint is violated, the full rejected string is recorded in the exception message in the query log.
Which ClickHouse versions are affected?
master
How to reproduce
^
Expected behavior
No response
Error message and/or stacktrace
No response
Additional context
No response