Merge pull request #60577 from Algunenano/format_print

Don't output number tips for date types
This commit is contained in:
Raúl Marín 2024-03-01 12:07:28 +01:00 committed by GitHub
commit 512f0d233e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 100 additions and 1 deletions

View File

@ -16,6 +16,7 @@ PrettyBlockOutputFormat::PrettyBlockOutputFormat(
WriteBuffer & out_, const Block & header_, const FormatSettings & format_settings_, bool mono_block_, bool color_)
: IOutputFormat(header_, out_), format_settings(format_settings_), serializations(header_.getSerializations()), color(color_), mono_block(mono_block_)
{
readable_number_tip = header_.getColumns().size() == 1 && WhichDataType(header_.getDataTypes()[0]->getTypeId()).isNumber();
}
@ -415,7 +416,7 @@ void PrettyBlockOutputFormat::writeSuffix()
void PrettyBlockOutputFormat::writeReadableNumberTip(const Chunk & chunk)
{
auto columns = chunk.getColumns();
auto is_single_number = chunk.getNumRows() == 1 && chunk.getNumColumns() == 1 && WhichDataType(columns[0]->getDataType()).isNumber();
auto is_single_number = readable_number_tip && chunk.getNumRows() == 1 && chunk.getNumColumns() == 1;
if (!is_single_number)
return;
auto value = columns[0]->getFloat64(0);

View File

@ -58,6 +58,7 @@ protected:
bool color;
private:
bool readable_number_tip = false;
bool mono_block;
/// For mono_block == true only
Chunk mono_chunk;

View File

@ -278,3 +278,83 @@
1000000000
1000000000
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CAST('2024-02-29', 'Date') ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2024-02-29 │
└────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CAST('2024-02-29', 'Date') ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2024-02-29 │
└────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CAST('2024-02-29', 'Date') ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2024-02-29 │
└────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CAST('2024-02-29', 'Date') ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2024-02-29 │
└────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CAST('2024-02-29', 'Date32') ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2024-02-29 │
└──────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CAST('2024-02-29', 'Date32') ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2024-02-29 │
└──────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CAST('2024-02-29', 'Date32') ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2024-02-29 │
└──────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CAST('2024-02-29', 'Date32') ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2024-02-29 │
└──────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CAST('2024-02-29 00:00:00', 'DateTime') ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2024-02-29 00:00:00 │
└─────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CAST('2024-02-29 00:00:00', 'DateTime') ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2024-02-29 00:00:00 │
└─────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CAST('2024-02-29 00:00:00', 'DateTime') ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2024-02-29 00:00:00 │
└─────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CAST('2024-02-29 00:00:00', 'DateTime') ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2024-02-29 00:00:00 │
└─────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CAST(CAST('2024-02-29 00:00:00', 'DateTime'), 'DateTime64') ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2024-02-29 00:00:00.000 │
└─────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CAST(CAST('2024-02-29 00:00:00', 'DateTime'), 'DateTime64') ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2024-02-29 00:00:00.000 │
└─────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CAST(CAST('2024-02-29 00:00:00', 'DateTime'), 'DateTime64') ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2024-02-29 00:00:00.000 │
└─────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CAST(CAST('2024-02-29 00:00:00', 'DateTime'), 'DateTime64') ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2024-02-29 00:00:00.000 │
└─────────────────────────────────────────────────────────────┘

View File

@ -77,3 +77,20 @@ SELECT 1_000_000_000 as a FROM system.numbers LIMIT 2 FORMAT PrettySpaceNoEscape
SELECT 1_000_000_000 as a FROM system.numbers LIMIT 2 FORMAT PrettySpaceMonoBlock;
SELECT 1_000_000_000 as a FROM system.numbers LIMIT 2 FORMAT PrettySpaceNoEscapesMonoBlock;
SET output_format_pretty_single_large_number_tip_threshold=1;
SELECT '2024-02-29'::Date FORMAT Pretty;
SELECT '2024-02-29'::Date FORMAT PrettyNoEscapes;
SELECT '2024-02-29'::Date FORMAT PrettyMonoBlock;
SELECT '2024-02-29'::Date FORMAT PrettyNoEscapesMonoBlock;
SELECT '2024-02-29'::Date32 FORMAT Pretty;
SELECT '2024-02-29'::Date32 FORMAT PrettyNoEscapes;
SELECT '2024-02-29'::Date32 FORMAT PrettyMonoBlock;
SELECT '2024-02-29'::Date32 FORMAT PrettyNoEscapesMonoBlock;
SELECT '2024-02-29 00:00:00'::DateTime FORMAT Pretty;
SELECT '2024-02-29 00:00:00'::DateTime FORMAT PrettyNoEscapes;
SELECT '2024-02-29 00:00:00'::DateTime FORMAT PrettyMonoBlock;
SELECT '2024-02-29 00:00:00'::DateTime FORMAT PrettyNoEscapesMonoBlock;
SELECT '2024-02-29 00:00:00'::DateTime::DateTime64 FORMAT Pretty;
SELECT '2024-02-29 00:00:00'::DateTime::DateTime64 FORMAT PrettyNoEscapes;
SELECT '2024-02-29 00:00:00'::DateTime::DateTime64 FORMAT PrettyMonoBlock;
SELECT '2024-02-29 00:00:00'::DateTime::DateTime64 FORMAT PrettyNoEscapesMonoBlock;