Merge pull request #59925 from Avogar/fix-json-http-crash

Fix crash in JSONColumnsWithMetadata format over http
This commit is contained in:
Kruglov Pavel 2024-02-14 11:58:18 +01:00 committed by GitHub
commit 0263826c15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 2 deletions

View File

@ -60,7 +60,7 @@ void registerInputFormatJSONColumnsWithMetadata(FormatFactory & factory)
factory.registerInputFormat(
"JSONColumnsWithMetadata",
[](ReadBuffer & buf,
const Block &sample,
const Block & sample,
const RowInputFormatParams &,
const FormatSettings & settings)
{

View File

@ -15,7 +15,7 @@ public:
bool checkChunkEnd() override;
private:
const Block & header;
const Block header;
const bool validate_types_from_metadata;
};

View File

@ -0,0 +1,3 @@
1 4
2 5
3 6

View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh
$CLICKHOUSE_CLIENT -q "drop table if exists test"
$CLICKHOUSE_CLIENT -q "create table test(x UInt32, y UInt32) engine=Memory"
echo -ne '{"meta":[{"name":"x","type":"UInt32"}, {"name":"y", "type":"UInt32"}],"data":{"x":[1,2,3],"y":[4,5,6]}}\n' | ${CLICKHOUSE_CURL} -sS "{$CLICKHOUSE_URL}&query=INSERT%20INTO%20test%20FORMAT%20JSONColumnsWithMetadata" --data-binary @-
$CLICKHOUSE_CLIENT -q "select * from test"
$CLICKHOUSE_CLIENT -q "drop table test"