Merge branch 'fix-bad-numbers-pretty-printing' into dont-cut-single-value

This commit is contained in:
Alexey Milovidov 2024-03-23 16:47:44 +01:00
commit d76fc0940a
8 changed files with 44 additions and 14 deletions

View File

@ -1,4 +1,3 @@
#include <boost/algorithm/string/join.hpp>
#include <cstdlib>
#include <fcntl.h>
#include <map>
@ -7,7 +6,6 @@
#include <memory>
#include <optional>
#include <Common/ThreadStatus.h>
#include <Common/scope_guard_safe.h>
#include <boost/program_options.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <filesystem>
@ -45,8 +43,6 @@
#include <Processors/Transforms/getSourceFromASTInsertQuery.h>
#include <Interpreters/InterpreterSetQuery.h>
#include <Functions/registerFunctions.h>
#include <AggregateFunctions/registerAggregateFunctions.h>
#include <Formats/registerFormats.h>
@ -1180,7 +1176,7 @@ void Client::processConfig()
pager = config().getString("pager", "");
is_default_format = !config().has("vertical") && !config().has("format");
is_default_format = !config().has("vertical") && !config().has("output-format") && !config().has("format");
if (is_default_format && checkIfStdoutIsRegularFile())
{
is_default_format = false;
@ -1189,9 +1185,13 @@ void Client::processConfig()
format = format_from_file_name ? *format_from_file_name : "TabSeparated";
}
else if (config().has("vertical"))
format = config().getString("format", "Vertical");
{
format = config().getString("output-format", config().getString("format", "Vertical"));
}
else
format = config().getString("format", is_interactive ? "PrettyCompact" : "TabSeparated");
{
format = config().getString("output-format", config().getString("format", is_interactive ? "PrettyCompact" : "TabSeparated"));
}
format_max_block_size = config().getUInt64("format_max_block_size",
global_context->getSettingsRef().max_block_size);

View File

@ -819,7 +819,6 @@ void LocalServer::addOptions(OptionsDescription & options_description)
("file,F", po::value<std::string>(), "path to file with data of the initial table (stdin if not specified)")
("input-format", po::value<std::string>(), "input format of the initial table data")
("output-format", po::value<std::string>(), "default output format")
("logger.console", po::value<bool>()->implicit_value(true), "Log to console")
("logger.log", po::value<std::string>(), "Log file name")

View File

@ -2892,7 +2892,9 @@ void ClientBase::init(int argc, char ** argv)
("suggestion_limit", po::value<int>()->default_value(10000), "Suggestion limit for how many databases, tables and columns to fetch.")
("format,f", po::value<std::string>(), "default output format")
("format,f", po::value<std::string>(), "default output format (and input format for clickhouse-local)")
("output-format", po::value<std::string>(), "default output format (this option has preference over --format)")
("vertical,E", "vertical output format, same as --format=Vertical or FORMAT Vertical or \\G at end of command")
("highlight", po::value<bool>()->default_value(true), "enable or disable basic syntax highlight in interactive command line")
@ -2975,6 +2977,8 @@ void ClientBase::init(int argc, char ** argv)
config().setBool("ignore-error", true);
if (options.count("format"))
config().setString("format", options["format"].as<std::string>());
if (options.count("output-format"))
config().setString("output-format", options["output-format"].as<std::string>());
if (options.count("vertical"))
config().setBool("vertical", true);
if (options.count("stacktrace"))

View File

@ -1387,7 +1387,6 @@ class TestCase:
self.reference_file,
self.stdout_file,
],
encoding="latin-1",
stdout=PIPE,
universal_newlines=True,
) as diff_proc:

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Tags: long
# Tags: long, no-debug
# Test fix for issue #5066

View File

@ -40,6 +40,6 @@
86.59 quadrillion 86.59 quadrillion 2.15 billion
235.39 quadrillion 235.39 quadrillion 2.15 billion
639.84 quadrillion 639.84 quadrillion 2.15 billion
1739.27 quadrillion 1739.27 quadrillion 2.15 billion
4727.84 quadrillion 4727.84 quadrillion 2.15 billion
12851.60 quadrillion 12851.60 quadrillion 2.15 billion
1.74 quintillion 1.74 quintillion 2.15 billion
4.73 quintillion 4.73 quintillion 2.15 billion
12.85 quintillion 12.85 quintillion 2.15 billion

View File

@ -0,0 +1,12 @@
| x |
|:-|
| Hello, world |
| x |
|:-|
| Hello, world |
| x |
|:-|
| Hello, world |
| x |
|:-|
| Hello, world |

View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
# clickhouse-local has --input-format and --output-format parameters,
# and also the --format parameter which is the default for both input and output formats, but has less preference.
# clickhouse-client does not have the --input-format parameter.
# However, it accepts both --format and --output-format for convenience.
${CLICKHOUSE_LOCAL} --output-format Markdown --query "SELECT 'Hello, world' AS x"
${CLICKHOUSE_CLIENT} --output-format Markdown --query "SELECT 'Hello, world' AS x"
${CLICKHOUSE_LOCAL} --format Markdown --query "SELECT 'Hello, world' AS x"
${CLICKHOUSE_CLIENT} --format Markdown --query "SELECT 'Hello, world' AS x"