Merge pull request #55298 from rschu1ze/use_mysql_types_in_show_columns

Make `use_mysql_types_in_show_columns` independent from the connection
This commit is contained in:
Robert Schulze 2023-10-07 22:03:24 +02:00 committed by GitHub
commit 312fe8e31d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 250 additions and 559 deletions

View File

@ -3279,6 +3279,17 @@ Possible values:
Default value: `0`.
## use_mysql_types_in_show_columns {#use_mysql_types_in_show_columns}
Show the names of MySQL data types corresponding to ClickHouse data types in [SHOW COLUMNS](../../sql-reference/statements/show.md#show_columns) and SELECTs on [system.columns](../system-tables/columns.md).
Possible values:
- 0 - Show names of native ClickHouse data types.
- 1 - Show names of MySQL data types corresponding to ClickHouse data types.
Default value: `0`.
## execute_merges_on_single_replica_time_threshold {#execute-merges-on-single-replica-time-threshold}
Enables special logic to perform merges on replicas.

View File

@ -14,7 +14,7 @@ The `system.columns` table contains the following columns (the column type is sh
- `database` ([String](../../sql-reference/data-types/string.md)) — Database name.
- `table` ([String](../../sql-reference/data-types/string.md)) — Table name.
- `name` ([String](../../sql-reference/data-types/string.md)) — Column name.
- `type` ([String](../../sql-reference/data-types/string.md)) — Column type.
- `type` ([String](../../sql-reference/data-types/string.md)) — Column type. If setting `[use_mysql_types_in_show_columns](../../operations/settings/settings.md#use_mysql_types_in_show_columns) = 1` (default: 0), then the equivalent type name in MySQL is shown.
- `position` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Ordinal position of a column in a table starting with 1.
- `default_kind` ([String](../../sql-reference/data-types/string.md)) — Expression type (`DEFAULT`, `MATERIALIZED`, `ALIAS`) for the default value, or an empty string if it is not defined.
- `default_expression` ([String](../../sql-reference/data-types/string.md)) — Expression for the default value, or an empty string if it is not defined.

View File

@ -189,7 +189,7 @@ Result:
- [Create Tables](https://clickhouse.com/docs/en/getting-started/tutorial/#create-tables)
- [SHOW CREATE TABLE](https://clickhouse.com/docs/en/sql-reference/statements/show/#show-create-table)
## SHOW COLUMNS
## SHOW COLUMNS {#show_columns}
Displays a list of columns
@ -206,15 +206,15 @@ The optional keyword `EXTENDED` currently has no effect, it only exists for MySQ
The optional keyword `FULL` causes the output to include the collation, comment and privilege columns.
The statement produces a result table with the following structure:
- field - The name of the column (String)
- type - The column data type (String)
- null - `YES` if the column data type is Nullable, `NO` otherwise (String)
- key - `PRI` if the column is part of the primary key, `SOR` if the column is part of the sorting key, empty otherwise (String)
- default - Default expression of the column if it is of type `ALIAS`, `DEFAULT`, or `MATERIALIZED`, otherwise `NULL`. (Nullable(String))
- extra - Additional information, currently unused (String)
- collation - (only if `FULL` keyword was specified) Collation of the column, always `NULL` because ClickHouse has no per-column collations (Nullable(String))
- comment - (only if `FULL` keyword was specified) Comment on the column (String)
- privilege - (only if `FULL` keyword was specified) The privilege you have on this column, currently not available (String)
- `field` - The name of the column (String)
- `type` - The column data type. If setting `[use_mysql_types_in_show_columns](../../operations/settings/settings.md#use_mysql_types_in_show_columns) = 1` (default: 0), then the equivalent type name in MySQL is shown. (String)
- `null` - `YES` if the column data type is Nullable, `NO` otherwise (String)
- `key` - `PRI` if the column is part of the primary key, `SOR` if the column is part of the sorting key, empty otherwise (String)
- `default` - Default expression of the column if it is of type `ALIAS`, `DEFAULT`, or `MATERIALIZED`, otherwise `NULL`. (Nullable(String))
- `extra` - Additional information, currently unused (String)
- `collation` - (only if `FULL` keyword was specified) Collation of the column, always `NULL` because ClickHouse has no per-column collations (Nullable(String))
- `comment` - (only if `FULL` keyword was specified) Comment on the column (String)
- `privilege` - (only if `FULL` keyword was specified) The privilege you have on this column, currently not available (String)
**Examples**
@ -286,21 +286,21 @@ equivalent. If no database is specified, the query assumes the current database
The optional keyword `EXTENDED` currently has no effect, it only exists for MySQL compatibility.
The statement produces a result table with the following structure:
- table - The name of the table. (String)
- non_unique - Always `1` as ClickHouse does not support uniqueness constraints. (UInt8)
- key_name - The name of the index, `PRIMARY` if the index is a primary key index. (String)
- seq_in_index - For a primary key index, the position of the column starting from `1`. For a data skipping index: always `1`. (UInt8)
- column_name - For a primary key index, the name of the column. For a data skipping index: `''` (empty string), see field "expression". (String)
- collation - The sorting of the column in the index: `A` if ascending, `D` if descending, `NULL` if unsorted. (Nullable(String))
- cardinality - An estimation of the index cardinality (number of unique values in the index). Currently always 0. (UInt64)
- sub_part - Always `NULL` because ClickHouse does not support index prefixes like MySQL. (Nullable(String))
- packed - Always `NULL` because ClickHouse does not support packed indexes (like MySQL). (Nullable(String))
- null - Currently unused
- index_type - The index type, e.g. `PRIMARY`, `MINMAX`, `BLOOM_FILTER` etc. (String)
- comment - Additional information about the index, currently always `''` (empty string). (String)
- index_comment - `''` (empty string) because indexes in ClickHouse cannot have a `COMMENT` field (like in MySQL). (String)
- visible - If the index is visible to the optimizer, always `YES`. (String)
- expression - For a data skipping index, the index expression. For a primary key index: `''` (empty string). (String)
- `table` - The name of the table. (String)
- `non_unique` - Always `1` as ClickHouse does not support uniqueness constraints. (UInt8)
- `key_name` - The name of the index, `PRIMARY` if the index is a primary key index. (String)
- `seq_in_index` - For a primary key index, the position of the column starting from `1`. For a data skipping index: always `1`. (UInt8)
- `column_name` - For a primary key index, the name of the column. For a data skipping index: `''` (empty string), see field "expression". (String)
- `collation` - The sorting of the column in the index: `A` if ascending, `D` if descending, `NULL` if unsorted. (Nullable(String))
- `cardinality` - An estimation of the index cardinality (number of unique values in the index). Currently always 0. (UInt64)
- `sub_part` - Always `NULL` because ClickHouse does not support index prefixes like MySQL. (Nullable(String))
- `packed` - Always `NULL` because ClickHouse does not support packed indexes (like MySQL). (Nullable(String))
- `null` - Currently unused
- `index_type` - The index type, e.g. `PRIMARY`, `MINMAX`, `BLOOM_FILTER` etc. (String)
- `comment` - Additional information about the index, currently always `''` (empty string). (String)
- `index_comment` - `''` (empty string) because indexes in ClickHouse cannot have a `COMMENT` field (like in MySQL). (String)
- `visible` - If the index is visible to the optimizer, always `YES`. (String)
- `expression` - For a data skipping index, the index expression. For a primary key index: `''` (empty string). (String)
**Examples**

View File

@ -205,7 +205,7 @@ class IColumn;
M(Bool, allow_experimental_inverted_index, false, "If it is set to true, allow to use experimental inverted index.", 0) \
\
M(UInt64, mysql_max_rows_to_insert, 65536, "The maximum number of rows in MySQL batch insertion of the MySQL storage engine", 0) \
M(Bool, use_mysql_types_in_show_columns, false, "Use MySQL converted types when connected via MySQL compatibility for show columns query", 0) \
M(Bool, use_mysql_types_in_show_columns, false, "Show MySQL types in SHOW COLUMNS and system.columns", 0) \
\
M(UInt64, optimize_min_equality_disjunction_chain_length, 3, "The minimum length of the expression `expr = x1 OR ... expr = xN` for optimization ", 0) \
\

View File

@ -132,18 +132,6 @@ protected:
bool check_access_for_columns = check_access_for_tables && !access->isGranted(AccessType::SHOW_COLUMNS, database_name, table_name);
auto get_type_name = [this](const IDataType& type) -> std::string
{
// Check if the use_mysql_types_in_show_columns setting is enabled and client is connected via MySQL protocol
if (use_mysql_types && client_info_interface == DB::ClientInfo::Interface::MYSQL)
{
return type.getSQLCompatibleName();
}
else
{
return type.getName();
}
};
size_t position = 0;
for (const auto & column : columns)
{
@ -161,7 +149,7 @@ protected:
if (columns_mask[src_index++])
res_columns[res_index++]->insert(column.name);
if (columns_mask[src_index++])
res_columns[res_index++]->insert(get_type_name(*column.type));
res_columns[res_index++]->insert(use_mysql_types ? (column.type->getSQLCompatibleName()) : (column.type->getName()));
if (columns_mask[src_index++])
res_columns[res_index++]->insert(position);

View File

@ -1,366 +1,148 @@
Drop tables if they exist
Create tab table
Create pseudo-random database name
Create tab duplicate table
Run MySQL test
field type null key default extra
aggregate_function AggregateFunction(sum, Int32) NO NULL
array_value Array(Int32) NO NULL
boolean_value UInt8 NO NULL
date32_value Date32 NO NULL
date_value Date NO NULL
datetime64_value DateTime64(3) NO NULL
datetime_value DateTime NO NULL
decimal_value Decimal(10, 2) NO NULL
enum_value Enum8('apple' = 1, 'banana' = 2, 'orange' = 3) NO NULL
fixed_string_value FixedString(10) NO NULL
float32 Float32 NO NULL
float64 Float64 NO NULL
int128 Int128 NO NULL
int16 Int16 NO NULL
int256 Int256 NO NULL
int32 Int32 NO NULL
int64 Int64 NO NULL
int8 Int8 NO NULL
ipv4_value IPv4 NO NULL
ipv6_value IPv6 NO NULL
json_value Object('json') NO NULL
low_cardinality LowCardinality(String) NO NULL
low_cardinality_date LowCardinality(DateTime) NO NULL
map_value Map(String, Int32) NO NULL
nested.nested_int Array(Int32) NO NULL
nested.nested_string Array(String) NO NULL
nint32 Nullable(Int32) YES NULL
nullable_value Nullable(Int32) YES NULL
string_value String NO NULL
tuple_value Tuple(Int32, String) NO NULL
uint128 UInt128 NO NULL
uint16 UInt16 NO NULL
uint256 UInt256 NO NULL
uint32 UInt32 NO NULL
uint64 UInt64 NO PRI SOR NULL
uint8 UInt8 NO NULL
uuid_value UUID NO NULL
field type null key default extra
aggregate_function TEXT NO NULL
array_value TEXT NO NULL
boolean_value TINYINT UNSIGNED NO NULL
date32_value DATE NO NULL
date_value DATE NO NULL
datetime64_value DATETIME NO NULL
datetime_value DATETIME NO NULL
decimal_value DECIMAL(10, 2) NO NULL
enum_value ENUM('apple', 'banana', 'orange') NO NULL
fixed_string_value TEXT NO NULL
float32 FLOAT NO NULL
float64 DOUBLE NO NULL
int128 TEXT NO NULL
int16 SMALLINT NO NULL
int256 TEXT NO NULL
int32 INTEGER NO NULL
int64 BIGINT NO NULL
int8 TINYINT NO NULL
ipv4_value TEXT NO NULL
ipv6_value TEXT NO NULL
json_value JSON NO NULL
low_cardinality BLOB NO NULL
low_cardinality_date DATETIME NO NULL
map_value JSON NO NULL
nested.nested_int TEXT NO NULL
nested.nested_string TEXT NO NULL
nint32 INTEGER NO NULL
nullable_value INTEGER NO NULL
string_value BLOB NO NULL
tuple_value JSON NO NULL
uint128 TEXT NO NULL
uint16 SMALLINT UNSIGNED NO NULL
uint256 TEXT NO NULL
uint32 INTEGER UNSIGNED NO NULL
uint64 BIGINT UNSIGNED NO PRI SOR NULL
uint8 TINYINT UNSIGNED NO NULL
uuid_value CHAR NO NULL
field type null key default extra
aggregate_function TEXT NO NULL
array_value TEXT NO NULL
boolean_value TINYINT UNSIGNED NO NULL
date32_value DATE NO NULL
date_value DATE NO NULL
datetime64_value DATETIME NO NULL
datetime_value DATETIME NO NULL
decimal_value DECIMAL(10, 2) NO NULL
enum_value ENUM('apple', 'banana', 'orange') NO NULL
fixed_string_value TEXT NO NULL
float32 FLOAT NO NULL
float64 DOUBLE NO NULL
int128 TEXT NO NULL
int16 SMALLINT NO NULL
int256 TEXT NO NULL
int32 INTEGER NO NULL
int64 BIGINT NO NULL
int8 TINYINT NO NULL
ipv4_value TEXT NO NULL
ipv6_value TEXT NO NULL
json_value JSON NO NULL
low_cardinality BLOB NO NULL
low_cardinality_date DATETIME NO NULL
map_value JSON NO NULL
nested.nested_int TEXT NO NULL
nested.nested_string TEXT NO NULL
nint32 INTEGER NO NULL
nullable_value INTEGER NO NULL
string_value BLOB NO NULL
tuple_value JSON NO NULL
uint128 TEXT NO NULL
uint16 SMALLINT UNSIGNED NO NULL
uint256 TEXT NO NULL
uint32 INTEGER UNSIGNED NO NULL
uint64 BIGINT UNSIGNED NO PRI SOR NULL
uint8 TINYINT UNSIGNED NO NULL
uuid_value CHAR NO NULL
field type null key default extra collation comment privileges
aggregate_function TEXT NO NULL NULL
array_value TEXT NO NULL NULL
boolean_value TINYINT UNSIGNED NO NULL NULL
date32_value DATE NO NULL NULL
date_value DATE NO NULL NULL
datetime64_value DATETIME NO NULL NULL
datetime_value DATETIME NO NULL NULL
decimal_value DECIMAL(10, 2) NO NULL NULL
enum_value ENUM('apple', 'banana', 'orange') NO NULL NULL
fixed_string_value TEXT NO NULL NULL
float32 FLOAT NO NULL NULL
float64 DOUBLE NO NULL NULL
int128 TEXT NO NULL NULL
int16 SMALLINT NO NULL NULL
int256 TEXT NO NULL NULL
int32 INTEGER NO NULL NULL
int64 BIGINT NO NULL NULL
int8 TINYINT NO NULL NULL
ipv4_value TEXT NO NULL NULL
ipv6_value TEXT NO NULL NULL
json_value JSON NO NULL NULL
low_cardinality BLOB NO NULL NULL
low_cardinality_date DATETIME NO NULL NULL
map_value JSON NO NULL NULL
nested.nested_int TEXT NO NULL NULL
nested.nested_string TEXT NO NULL NULL
nint32 INTEGER NO NULL NULL
nullable_value INTEGER NO NULL NULL
string_value BLOB NO NULL NULL
tuple_value JSON NO NULL NULL
uint128 TEXT NO NULL NULL
uint16 SMALLINT UNSIGNED NO NULL NULL
uint256 TEXT NO NULL NULL
uint32 INTEGER UNSIGNED NO NULL NULL
uint64 BIGINT UNSIGNED NO PRI SOR NULL NULL
uint8 TINYINT UNSIGNED NO NULL NULL
uuid_value CHAR NO NULL NULL
field type null key default extra
int128 TEXT NO NULL
int16 SMALLINT NO NULL
int256 TEXT NO NULL
int32 INTEGER NO NULL
int64 BIGINT NO NULL
int8 TINYINT NO NULL
nested.nested_int TEXT NO NULL
nint32 INTEGER NO NULL
uint128 TEXT NO NULL
uint16 SMALLINT UNSIGNED NO NULL
uint256 TEXT NO NULL
uint32 INTEGER UNSIGNED NO NULL
uint64 BIGINT UNSIGNED NO PRI SOR NULL
uint8 TINYINT UNSIGNED NO NULL
field type null key default extra
aggregate_function TEXT NO NULL
array_value TEXT NO NULL
boolean_value TINYINT UNSIGNED NO NULL
date32_value DATE NO NULL
date_value DATE NO NULL
datetime64_value DATETIME NO NULL
datetime_value DATETIME NO NULL
decimal_value DECIMAL(10, 2) NO NULL
enum_value ENUM('apple', 'banana', 'orange') NO NULL
fixed_string_value TEXT NO NULL
float32 FLOAT NO NULL
float64 DOUBLE NO NULL
ipv4_value TEXT NO NULL
ipv6_value TEXT NO NULL
json_value JSON NO NULL
low_cardinality BLOB NO NULL
low_cardinality_date DATETIME NO NULL
map_value JSON NO NULL
nested.nested_string TEXT NO NULL
nullable_value INTEGER NO NULL
string_value BLOB NO NULL
tuple_value JSON NO NULL
uuid_value CHAR NO NULL
field type null key default extra
int128 TEXT NO NULL
int16 SMALLINT NO NULL
int256 TEXT NO NULL
int32 INTEGER NO NULL
int64 BIGINT NO NULL
int8 TINYINT NO NULL
nested.nested_int TEXT NO NULL
nint32 INTEGER NO NULL
uint128 TEXT NO NULL
uint16 SMALLINT UNSIGNED NO NULL
uint256 TEXT NO NULL
uint32 INTEGER UNSIGNED NO NULL
uint64 BIGINT UNSIGNED NO PRI SOR NULL
uint8 TINYINT UNSIGNED NO NULL
field type null key default extra
aggregate_function TEXT NO NULL
array_value TEXT NO NULL
boolean_value TINYINT UNSIGNED NO NULL
date32_value DATE NO NULL
date_value DATE NO NULL
datetime64_value DATETIME NO NULL
datetime_value DATETIME NO NULL
decimal_value DECIMAL(10, 2) NO NULL
enum_value ENUM('apple', 'banana', 'orange') NO NULL
fixed_string_value TEXT NO NULL
float32 FLOAT NO NULL
float64 DOUBLE NO NULL
ipv4_value TEXT NO NULL
ipv6_value TEXT NO NULL
json_value JSON NO NULL
low_cardinality BLOB NO NULL
low_cardinality_date DATETIME NO NULL
map_value JSON NO NULL
nested.nested_string TEXT NO NULL
nullable_value INTEGER NO NULL
string_value BLOB NO NULL
tuple_value JSON NO NULL
uuid_value CHAR NO NULL
field type null key default extra
int128 TEXT NO NULL
int16 SMALLINT NO NULL
int256 TEXT NO NULL
int32 INTEGER NO NULL
int64 BIGINT NO NULL
int8 TINYINT NO NULL
nested.nested_int TEXT NO NULL
nint32 INTEGER NO NULL
uint128 TEXT NO NULL
uint16 SMALLINT UNSIGNED NO NULL
uint256 TEXT NO NULL
uint32 INTEGER UNSIGNED NO NULL
uint64 BIGINT UNSIGNED NO PRI SOR NULL
uint8 TINYINT UNSIGNED NO NULL
field type null key default extra
aggregate_function TEXT NO NULL
field type null key default extra
aggregate_function TEXT NO NULL
array_value TEXT NO NULL
boolean_value TINYINT UNSIGNED NO NULL
date32_value DATE NO NULL
date_value DATE NO NULL
datetime64_value DATETIME NO NULL
datetime_value DATETIME NO NULL
decimal_value DECIMAL(10, 2) NO NULL
enum_value ENUM('apple', 'banana', 'orange') NO NULL
fixed_string_value TEXT NO NULL
float32 FLOAT NO NULL
float64 DOUBLE NO NULL
int128 TEXT NO NULL
int16 SMALLINT NO NULL
int256 TEXT NO NULL
int32 INTEGER NO NULL
int64 BIGINT NO NULL
int8 TINYINT NO NULL
ipv4_value TEXT NO NULL
ipv6_value TEXT NO NULL
json_value JSON NO NULL
low_cardinality BLOB NO NULL
low_cardinality_date DATETIME NO NULL
map_value JSON NO NULL
nested.nested_int TEXT NO NULL
nested.nested_string TEXT NO NULL
nint32 INTEGER NO NULL
nullable_value INTEGER NO NULL
string_value BLOB NO NULL
tuple_value JSON NO NULL
uint128 TEXT NO NULL
uint16 SMALLINT UNSIGNED NO NULL
uint256 TEXT NO NULL
uint32 INTEGER UNSIGNED NO NULL
uint64 BIGINT UNSIGNED NO PRI SOR NULL
uint8 TINYINT UNSIGNED NO NULL
uuid_value CHAR NO NULL
field type null key default extra
aggregate_function TEXT NO NULL
array_value TEXT NO NULL
boolean_value TINYINT UNSIGNED NO NULL
date32_value DATE NO NULL
date_value DATE NO NULL
datetime64_value DATETIME NO NULL
datetime_value DATETIME NO NULL
decimal_value DECIMAL(10, 2) NO NULL
enum_value ENUM('apple', 'banana', 'orange') NO NULL
fixed_string_value TEXT NO NULL
float32 FLOAT NO NULL
float64 DOUBLE NO NULL
int128 TEXT NO NULL
int16 SMALLINT NO NULL
int256 TEXT NO NULL
int32 INTEGER NO NULL
int64 BIGINT NO NULL
int8 TINYINT NO NULL
ipv4_value TEXT NO NULL
ipv6_value TEXT NO NULL
json_value JSON NO NULL
low_cardinality BLOB NO NULL
low_cardinality_date DATETIME NO NULL
map_value JSON NO NULL
nested.nested_int TEXT NO NULL
nested.nested_string TEXT NO NULL
nint32 INTEGER NO NULL
nullable_value INTEGER NO NULL
string_value BLOB NO NULL
tuple_value JSON NO NULL
uint128 TEXT NO NULL
uint16 SMALLINT UNSIGNED NO NULL
uint256 TEXT NO NULL
uint32 INTEGER UNSIGNED NO NULL
uint64 BIGINT UNSIGNED NO PRI SOR NULL
uint8 TINYINT UNSIGNED NO NULL
uuid_value CHAR NO NULL
field type null key default extra
aggregate_function TEXT NO NULL
array_value TEXT NO NULL
boolean_value TINYINT UNSIGNED NO NULL
date32_value DATE NO NULL
date_value DATE NO NULL
datetime64_value DATETIME NO NULL
datetime_value DATETIME NO NULL
decimal_value DECIMAL(10, 2) NO NULL
enum_value ENUM('apple', 'banana', 'orange') NO NULL
fixed_string_value TEXT NO NULL
float32 FLOAT NO NULL
float64 DOUBLE NO NULL
int128 TEXT NO NULL
int16 SMALLINT NO NULL
int256 TEXT NO NULL
int32 INTEGER NO NULL
int64 BIGINT NO NULL
int8 TINYINT NO NULL
ipv4_value TEXT NO NULL
ipv6_value TEXT NO NULL
json_value JSON NO NULL
low_cardinality BLOB NO NULL
low_cardinality_date DATETIME NO NULL
map_value JSON NO NULL
nested.nested_int TEXT NO NULL
nested.nested_string TEXT NO NULL
nint32 INTEGER NO NULL
nullable_value INTEGER NO NULL
string_value BLOB NO NULL
tuple_value JSON NO NULL
uint128 TEXT NO NULL
uint16 SMALLINT UNSIGNED NO NULL
uint256 TEXT NO NULL
uint32 INTEGER UNSIGNED NO NULL
uint64 BIGINT UNSIGNED NO PRI SOR NULL
uint8 TINYINT UNSIGNED NO NULL
uuid_value CHAR NO NULL
aggregate_function AggregateFunction(sum, Int32) NO \N
array_value Array(Int32) NO \N
boolean_value UInt8 NO \N
date32_value Date32 NO \N
date_value Date NO \N
datetime64_value DateTime64(3) NO \N
datetime_value DateTime NO \N
decimal_value Decimal(10, 2) NO \N
enum_value Enum8(\'apple\' = 1, \'banana\' = 2, \'orange\' = 3) NO \N
fixed_string_value FixedString(10) NO \N
float32 Float32 NO \N
float64 Float64 NO \N
int128 Int128 NO \N
int16 Int16 NO \N
int256 Int256 NO \N
int32 Int32 NO \N
int64 Int64 NO \N
int8 Int8 NO \N
ipv4_value IPv4 NO \N
ipv6_value IPv6 NO \N
json_value Object(\'json\') NO \N
low_cardinality LowCardinality(String) NO \N
low_cardinality_date LowCardinality(DateTime) NO \N
map_value Map(String, Int32) NO \N
nested.nested_int Array(Int32) NO \N
nested.nested_string Array(String) NO \N
nint32 Nullable(Int32) YES \N
nullable_value Nullable(Int32) YES \N
string_value String NO \N
tuple_value Tuple(Int32, String) NO \N
uint128 UInt128 NO \N
uint16 UInt16 NO \N
uint256 UInt256 NO \N
uint32 UInt32 NO \N
uint64 UInt64 NO PRI SOR \N
uint8 UInt8 NO \N
uuid_value UUID NO \N
aggregate_function TEXT NO \N
array_value TEXT NO \N
boolean_value TINYINT UNSIGNED NO \N
date32_value DATE NO \N
date_value DATE NO \N
datetime64_value DATETIME NO \N
datetime_value DATETIME NO \N
decimal_value DECIMAL(10, 2) NO \N
enum_value ENUM(\'apple\', \'banana\', \'orange\') NO \N
fixed_string_value TEXT NO \N
float32 FLOAT NO \N
float64 DOUBLE NO \N
int128 TEXT NO \N
int16 SMALLINT NO \N
int256 TEXT NO \N
int32 INTEGER NO \N
int64 BIGINT NO \N
int8 TINYINT NO \N
ipv4_value TEXT NO \N
ipv6_value TEXT NO \N
json_value JSON NO \N
low_cardinality BLOB NO \N
low_cardinality_date DATETIME NO \N
map_value JSON NO \N
nested.nested_int TEXT NO \N
nested.nested_string TEXT NO \N
nint32 INTEGER NO \N
nullable_value INTEGER NO \N
string_value BLOB NO \N
tuple_value JSON NO \N
uint128 TEXT NO \N
uint16 SMALLINT UNSIGNED NO \N
uint256 TEXT NO \N
uint32 INTEGER UNSIGNED NO \N
uint64 BIGINT UNSIGNED NO PRI SOR \N
uint8 TINYINT UNSIGNED NO \N
uuid_value CHAR NO \N
uint8 UInt8
uint16 UInt16
uint32 UInt32
uint64 UInt64
uint128 UInt128
uint256 UInt256
int8 Int8
int16 Int16
int32 Int32
int64 Int64
int128 Int128
int256 Int256
nint32 Nullable(Int32)
float32 Float32
float64 Float64
decimal_value Decimal(10, 2)
boolean_value UInt8
string_value String
fixed_string_value FixedString(10)
date_value Date
date32_value Date32
datetime_value DateTime
datetime64_value DateTime64(3)
json_value Object(\'json\')
uuid_value UUID
enum_value Enum8(\'apple\' = 1, \'banana\' = 2, \'orange\' = 3)
low_cardinality LowCardinality(String)
low_cardinality_date LowCardinality(DateTime)
aggregate_function AggregateFunction(sum, Int32)
array_value Array(Int32)
map_value Map(String, Int32)
tuple_value Tuple(Int32, String)
nullable_value Nullable(Int32)
ipv4_value IPv4
ipv6_value IPv6
nested.nested_int Array(Int32)
nested.nested_string Array(String)
uint8 TINYINT UNSIGNED
uint16 SMALLINT UNSIGNED
uint32 INTEGER UNSIGNED
uint64 BIGINT UNSIGNED
uint128 TEXT
uint256 TEXT
int8 TINYINT
int16 SMALLINT
int32 INTEGER
int64 BIGINT
int128 TEXT
int256 TEXT
nint32 INTEGER
float32 FLOAT
float64 DOUBLE
decimal_value DECIMAL(10, 2)
boolean_value TINYINT UNSIGNED
string_value BLOB
fixed_string_value TEXT
date_value DATE
date32_value DATE
datetime_value DATETIME
datetime64_value DATETIME
json_value JSON
uuid_value CHAR
enum_value ENUM(\'apple\', \'banana\', \'orange\')
low_cardinality BLOB
low_cardinality_date DATETIME
aggregate_function TEXT
array_value TEXT
map_value JSON
tuple_value JSON
nullable_value INTEGER
ipv4_value TEXT
ipv6_value TEXT
nested.nested_int TEXT
nested.nested_string TEXT

View File

@ -1,153 +0,0 @@
#!/usr/bin/env bash
# Tags: no-fasttest, no-parallel
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
# This script tests the MySQL compatibility of the SHOW COLUMNS command in ClickHouse
USER="default"
PASSWORD=""
HOST="127.0.0.1"
PORT=9004
# First run the clickhouse test to create the ClickHouse Tables
echo "Drop tables if they exist"
${CLICKHOUSE_CLIENT} --query "DROP TABLE IF EXISTS tab"
${CLICKHOUSE_CLIENT} --query "DROP DATABASE IF EXISTS database_123456789abcdef"
${CLICKHOUSE_CLIENT} --query "DROP TABLE IF EXISTS database_123456789abcdef.tab"
echo "Create tab table "
${CLICKHOUSE_CLIENT} -n -q "
SET allow_suspicious_low_cardinality_types=1;
SET allow_experimental_object_type=1;
CREATE TABLE tab
(
uint8 UInt8,
uint16 UInt16,
uint32 UInt32,
uint64 UInt64,
uint128 UInt128,
uint256 UInt256,
int8 Int8,
int16 Int16,
int32 Int32,
int64 Int64,
int128 Int128,
int256 Int256,
nint32 Nullable(Int32),
float32 Float32,
float64 Float64,
decimal_value Decimal(10, 2),
boolean_value UInt8,
string_value String,
fixed_string_value FixedString(10),
date_value Date,
date32_value Date32,
datetime_value DateTime,
datetime64_value DateTime64(3),
json_value JSON,
uuid_value UUID,
enum_value Enum8('apple' = 1, 'banana' = 2, 'orange' = 3),
low_cardinality LowCardinality(String),
low_cardinality_date LowCardinality(DateTime),
aggregate_function AggregateFunction(sum, Int32),
array_value Array(Int32),
map_value Map(String, Int32),
tuple_value Tuple(Int32, String),
nullable_value Nullable(Int32),
ipv4_value IPv4,
ipv6_value IPv6,
nested Nested
(
nested_int Int32,
nested_string String
)
) ENGINE = MergeTree
ORDER BY uint64;
"
echo "Create pseudo-random database name"
${CLICKHOUSE_CLIENT} --query "CREATE DATABASE database_123456789abcdef;"
echo "Create tab duplicate table"
${CLICKHOUSE_CLIENT} -n -q "
SET allow_suspicious_low_cardinality_types=1;
SET allow_experimental_object_type =1;
CREATE TABLE database_123456789abcdef.tab
(
uint8 UInt8,
uint16 UInt16,
uint32 UInt32,
uint64 UInt64,
uint128 UInt128,
uint256 UInt256,
int8 Int8,
int16 Int16,
int32 Int32,
int64 Int64,
int128 Int128,
int256 Int256,
nint32 Nullable(Int32),
float32 Float32,
float64 Float64,
decimal_value Decimal(10, 2),
boolean_value UInt8,
string_value String,
fixed_string_value FixedString(10),
date_value Date,
date32_value Date32,
datetime_value DateTime,
datetime64_value DateTime64(3),
json_value JSON,
uuid_value UUID,
enum_value Enum8('apple' = 1, 'banana' = 2, 'orange' = 3),
low_cardinality LowCardinality(String),
low_cardinality_date LowCardinality(DateTime),
aggregate_function AggregateFunction(sum, Int32),
array_value Array(Int32),
map_value Map(String, Int32),
tuple_value Tuple(Int32, String),
nullable_value Nullable(Int32),
ipv4_value IPv4,
ipv6_value IPv6,
nested Nested
(
nested_int Int32,
nested_string String
)
) ENGINE = MergeTree
ORDER BY uint64;
"
# Write sql to temp file
TEMP_FILE=$(mktemp)
cat <<EOT > $TEMP_FILE
SHOW COLUMNS FROM tab;
SET use_mysql_types_in_show_columns=1;
SHOW COLUMNS FROM tab;
SHOW EXTENDED COLUMNS FROM tab;
SHOW FULL COLUMNS FROM tab;
SHOW COLUMNS FROM tab LIKE '%int%';
SHOW COLUMNS FROM tab NOT LIKE '%int%';
SHOW COLUMNS FROM tab ILIKE '%INT%';
SHOW COLUMNS FROM tab NOT ILIKE '%INT%';
SHOW COLUMNS FROM tab WHERE field LIKE '%int%';
SHOW COLUMNS FROM tab LIMIT 1;
SHOW COLUMNS FROM tab;
SHOW COLUMNS FROM tab FROM database_123456789abcdef;
SHOW COLUMNS FROM database_123456789abcdef.tab;
DROP DATABASE database_123456789abcdef;
DROP TABLE tab;
EOT
# Now run the MySQL test script on the ClickHouse DB
echo "Run MySQL test"
MYSQL_PWD=$PASSWORD ${MYSQL_CLIENT} --user="$USER" --host="$HOST" --port="$PORT" < $TEMP_FILE
# Clean up the temp file
rm $TEMP_FILE

View File

@ -0,0 +1,63 @@
-- Tags: no-fasttest, no-parallel
-- no-fasttest: json type needs rapidjson library
-- no-parallel: can't provide currentDatabase() to SHOW COLUMNS
-- Tests setting 'use_mysql_types_in_show_columns' in SHOW COLUMNS and SELECTs on system.columns
DROP TABLE IF EXISTS tab;
SET allow_suspicious_low_cardinality_types=1;
SET allow_experimental_object_type=1;
CREATE TABLE tab
(
uint8 UInt8,
uint16 UInt16,
uint32 UInt32,
uint64 UInt64,
uint128 UInt128,
uint256 UInt256,
int8 Int8,
int16 Int16,
int32 Int32,
int64 Int64,
int128 Int128,
int256 Int256,
nint32 Nullable(Int32),
float32 Float32,
float64 Float64,
decimal_value Decimal(10, 2),
boolean_value UInt8,
string_value String,
fixed_string_value FixedString(10),
date_value Date,
date32_value Date32,
datetime_value DateTime,
datetime64_value DateTime64(3),
json_value JSON,
uuid_value UUID,
enum_value Enum8('apple' = 1, 'banana' = 2, 'orange' = 3),
low_cardinality LowCardinality(String),
low_cardinality_date LowCardinality(DateTime),
aggregate_function AggregateFunction(sum, Int32),
array_value Array(Int32),
map_value Map(String, Int32),
tuple_value Tuple(Int32, String),
nullable_value Nullable(Int32),
ipv4_value IPv4,
ipv6_value IPv6,
nested Nested
(
nested_int Int32,
nested_string String
)
) ENGINE = MergeTree
ORDER BY uint64;
SHOW COLUMNS FROM tab SETTINGS use_mysql_types_in_show_columns = 0;
SHOW COLUMNS FROM tab SETTINGS use_mysql_types_in_show_columns = 1;
SELECT name, type FROM system.columns WHERE database = currentDatabase() AND table = 'tab' SETTINGS use_mysql_types_in_show_columns = 0;
SELECT name, type FROM system.columns WHERE database = currentDatabase() AND table = 'tab' SETTINGS use_mysql_types_in_show_columns = 1;
DROP TABLE tab;