diff --git a/src/Client/ClientBase.cpp b/src/Client/ClientBase.cpp index 465d4358e91..c96982bd0b8 100644 --- a/src/Client/ClientBase.cpp +++ b/src/Client/ClientBase.cpp @@ -1129,6 +1129,7 @@ void ClientBase::processInsertQuery(const String & query_to_execute, ASTPtr pars { /// If structure was received (thus, server has not thrown an exception), /// send our data with that structure. + std::cerr << "database: " << global_context->resolveStorageID(parsed_insert_query.table_id).getDatabaseName() << "\n"; sendData(sample, columns_description, parsed_query); receiveEndOfQuery(); } diff --git a/src/Core/Settings.h b/src/Core/Settings.h index ae6bcbd1bf9..8853d022054 100644 --- a/src/Core/Settings.h +++ b/src/Core/Settings.h @@ -757,7 +757,7 @@ static constexpr UInt64 operator""_GiB(unsigned long long value) M(Bool, output_format_json_escape_forward_slashes, true, "Controls escaping forward slashes for string outputs in JSON output format. This is intended for compatibility with JavaScript. Don't confuse with backslashes that are always escaped.", 0) \ M(Bool, output_format_json_named_tuples_as_objects, true, "Serialize named tuple columns as JSON objects.", 0) \ M(Bool, output_format_json_array_of_rows, false, "Output a JSON array of all rows in JSONEachRow(Compact) format.", 0) \ - M(Bool, output_format_json_validate_utf8, false, "Validate UTF-8 sequences in JSON output formats, don't impact formats JSON/JSONCompact/JSONColumnsWithMetadata, they always validate utf8 ", 0) \ + M(Bool, output_format_json_validate_utf8, false, "Validate UTF-8 sequences in JSON output formats, doesn't impact formats JSON/JSONCompact/JSONColumnsWithMetadata, they always validate utf8", 0) \ \ M(UInt64, output_format_pretty_max_rows, 10000, "Rows limit for Pretty formats.", 0) \ M(UInt64, output_format_pretty_max_column_pad_width, 250, "Maximum width to pad all values in a column in Pretty formats.", 0) \ diff --git a/src/DataTypes/Serializations/SerializationString.cpp b/src/DataTypes/Serializations/SerializationString.cpp index b17fcd6964a..b3254971085 100644 --- a/src/DataTypes/Serializations/SerializationString.cpp +++ b/src/DataTypes/Serializations/SerializationString.cpp @@ -21,6 +21,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int INCORRECT_DATA; +} + void SerializationString::serializeBinary(const Field & field, WriteBuffer & ostr) const { const String & s = get(field); diff --git a/src/Formats/EscapingRuleUtils.cpp b/src/Formats/EscapingRuleUtils.cpp index 17a93ef8181..ef554ecdcdf 100644 --- a/src/Formats/EscapingRuleUtils.cpp +++ b/src/Formats/EscapingRuleUtils.cpp @@ -383,8 +383,6 @@ void transformInferredTypesIfNeededImpl(DataTypes & types, const FormatSettings } } } - - }; auto transform_complex_types = [&](DataTypes & data_types) diff --git a/src/Interpreters/executeQuery.cpp b/src/Interpreters/executeQuery.cpp index c501c1722ba..2603257d376 100644 --- a/src/Interpreters/executeQuery.cpp +++ b/src/Interpreters/executeQuery.cpp @@ -544,9 +544,15 @@ static std::tuple executeQueryImpl( if (insert_query) { if (insert_query->table_id) + { insert_query->table_id = context->resolveStorageID(insert_query->table_id); + LOG_DEBUG(&Poco::Logger::get("executeQuery"), "2) database: {}", insert_query->table_id.getDatabaseName()); + } else if (auto table = insert_query->getTable(); !table.empty()) + { insert_query->table_id = context->resolveStorageID(StorageID{insert_query->getDatabase(), table}); + LOG_DEBUG(&Poco::Logger::get("executeQuery"), "2) database: {}", insert_query->table_id.getDatabaseName()); + } } if (insert_query && insert_query->select) diff --git a/src/Processors/Formats/Impl/JSONColumnsWithMetadataBlockInputFormat.cpp b/src/Processors/Formats/Impl/JSONColumnsWithMetadataBlockInputFormat.cpp index dfd76f3bb8f..711b78324ac 100644 --- a/src/Processors/Formats/Impl/JSONColumnsWithMetadataBlockInputFormat.cpp +++ b/src/Processors/Formats/Impl/JSONColumnsWithMetadataBlockInputFormat.cpp @@ -7,6 +7,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int INCORRECT_DATA; +} + JSONColumnsWithMetadataReader::JSONColumnsWithMetadataReader(ReadBuffer & in_, const Block & header_, const FormatSettings & settings) : JSONColumnsReader(in_), header(header_), use_metadata(settings.json.use_metadata) { diff --git a/src/Processors/Formats/Impl/JSONColumnsWithMetadataBlockInputFormat.h b/src/Processors/Formats/Impl/JSONColumnsWithMetadataBlockInputFormat.h index 8efcbdba2e3..da56cd59872 100644 --- a/src/Processors/Formats/Impl/JSONColumnsWithMetadataBlockInputFormat.h +++ b/src/Processors/Formats/Impl/JSONColumnsWithMetadataBlockInputFormat.h @@ -6,13 +6,6 @@ namespace DB { -/* Format JSONCompactColumns reads each block of data in the next format: - * [ - * [value1, value2, value3, ...], - * [value1, value2m value3, ...], - * ... - * ] - */ class JSONColumnsWithMetadataReader : public JSONColumnsReader { public: diff --git a/src/Processors/Formats/Impl/JSONObjectEachRowRowInputFormat.h b/src/Processors/Formats/Impl/JSONObjectEachRowRowInputFormat.h index 0891f43fe6e..fd98f43649f 100644 --- a/src/Processors/Formats/Impl/JSONObjectEachRowRowInputFormat.h +++ b/src/Processors/Formats/Impl/JSONObjectEachRowRowInputFormat.h @@ -29,8 +29,6 @@ private: void readSuffix() override {} void readRowStart() override; bool checkEndOfData(bool is_first_row) override; - -// size_t row = 0; }; diff --git a/src/Processors/Formats/Impl/JSONObjectEachRowRowOutputFormat.h b/src/Processors/Formats/Impl/JSONObjectEachRowRowOutputFormat.h index 8132cac1db0..51db22fb606 100644 --- a/src/Processors/Formats/Impl/JSONObjectEachRowRowOutputFormat.h +++ b/src/Processors/Formats/Impl/JSONObjectEachRowRowOutputFormat.h @@ -9,6 +9,14 @@ namespace DB { +/* Outputs data as a single JSON Object with rows as fields: + * { + * "row_1": {"num": 42, "str": "hello", "arr": [0,1]}, + * "row_2": {"num": 43, "str": "hello", "arr": [0,1,2]}, + * "row_3": {"num": 44, "str": "hello", "arr": [0,1,2,3]}, + * } + */ + class JSONObjectEachRowRowOutputFormat : public JSONEachRowRowOutputFormat { public: diff --git a/src/Processors/Formats/Impl/JSONRowInputFormat.h b/src/Processors/Formats/Impl/JSONRowInputFormat.h index a599ca809df..838610d4112 100644 --- a/src/Processors/Formats/Impl/JSONRowInputFormat.h +++ b/src/Processors/Formats/Impl/JSONRowInputFormat.h @@ -4,7 +4,6 @@ #include #include #include -#include namespace DB diff --git a/tests/queries/0_stateless/02422_read_numbers_as_strings.sql b/tests/queries/0_stateless/02422_read_numbers_as_strings.sql index cab695ce74c..00aab22a64c 100644 --- a/tests/queries/0_stateless/02422_read_numbers_as_strings.sql +++ b/tests/queries/0_stateless/02422_read_numbers_as_strings.sql @@ -1,3 +1,6 @@ +-- Tags: no-fasttest + select * from format(JSONEachRow, '{"x" : 123}\n{"x" : "str"}'); select * from format(JSONEachRow, '{"x" : [123, "str"]}'); select * from format(JSONEachRow, '{"x" : [123, "456"]}\n{"x" : ["str", "rts"]}'); + diff --git a/utils/check-style/aspell-ignore/en/aspell-dict.txt b/utils/check-style/aspell-ignore/en/aspell-dict.txt index fa178e764da..1f290fb2b5b 100644 --- a/utils/check-style/aspell-ignore/en/aspell-dict.txt +++ b/utils/check-style/aspell-ignore/en/aspell-dict.txt @@ -64,6 +64,7 @@ JSONCompactStringsEachRowWithNames JSONCompactStringsEachRowWithNamesAndTypes JSONEachRow JSONEachRowWithProgress +JSONObjectEachRow JSONStrings JSONStringsEachRow JSONStringsEachRowWithProgress @@ -299,6 +300,7 @@ jsoncompactstringseachrowwithnames jsoncompactstringseachrowwithnamesandtypes jsoneachrow jsoneachrowwithprogress +jsonobjecteachrow jsonstrings jsonstringseachrow jsonstringseachrowwithprogress