Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix possible clickhouse-local abort on JSONEachRow schema inference #46731

Merged
merged 4 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/Core/NamesAndTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,17 @@ struct NameAndTypePair
/// This needed to use structured bindings for NameAndTypePair
/// const auto & [name, type] = name_and_type
template <int I>
decltype(auto) get(const NameAndTypePair & name_and_type)
const std::tuple_element_t<I, NameAndTypePair> & get(const NameAndTypePair & name_and_type)
{
if constexpr (I == 0)
return name_and_type.name;
else if constexpr (I == 1)
return name_and_type.type;
}

/// auto & [name, type] = name_and_type
template <int I>
std::tuple_element_t<I, NameAndTypePair> & get(NameAndTypePair & name_and_type)
{
if constexpr (I == 0)
return name_and_type.name;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh

$CLICKHOUSE_LOCAL -q "desc file('$CUR_DIR/data_json/twitter.jsonl')" 2>&1 | grep -c "ONLY_NULLS_WHILE_READING_SCHEMA"

1 change: 1 addition & 0 deletions tests/queries/0_stateless/data_json/twitter.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"created_at":"Wed Jul 01 06:29:00 +0000 2020","id":1278214001395216384,"id_str":"1278214001395216384","text":"\u00c8 SICUROOOOO?","source":"\u003ca href=\"https:\/\/elenoireferruzzibot.com\" rel=\"nofollow\"\u003eBotElenoire\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":1191418444324966403,"id_str":"1191418444324966403","name":"Elenoire Ferruzzi Bot","screen_name":"BotElenoire","location":null,"url":null,"description":"L\u2019importante \u00e8 averli puliti","translator_type":"none","protected":false,"verified":false,"followers_count":1239,"friends_count":3,"listed_count":1,"favourites_count":12,"statuses_count":20769,"created_at":"Mon Nov 04 18:14:32 +0000 2019","utc_offset":null,"time_zone":null,"geo_enabled":false,"lang":null,"contributors_enabled":false,"is_translator":false,"profile_background_color":"F5F8FA","profile_background_image_url":"","profile_background_image_url_https":"","profile_background_tile":false,"profile_link_color":"1DA1F2","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/1191422843084521472\/HEy5I5g8_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/1191422843084521472\/HEy5I5g8_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/1191418444324966403\/1578228379","default_profile":true,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"quote_count":0,"reply_count":0,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[],"urls":[],"user_mentions":[],"symbols":[]},"favorited":false,"retweeted":false,"filter_level":"low","lang":"it","timestamp_ms":"1593584940657"}