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`. 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} ## execute_merges_on_single_replica_time_threshold {#execute-merges-on-single-replica-time-threshold}
Enables special logic to perform merges on replicas. 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. - `database` ([String](../../sql-reference/data-types/string.md)) — Database name.
- `table` ([String](../../sql-reference/data-types/string.md)) — Table name. - `table` ([String](../../sql-reference/data-types/string.md)) — Table name.
- `name` ([String](../../sql-reference/data-types/string.md)) — Column 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. - `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_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. - `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) - [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 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 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 optional keyword `FULL` causes the output to include the collation, comment and privilege columns.
The statement produces a result table with the following structure: The statement produces a result table with the following structure:
- field - The name of the column (String) - `field` - The name of the column (String)
- type - The column data type (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) - `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) - `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)) - `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) - `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)) - `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) - `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) - `privilege` - (only if `FULL` keyword was specified) The privilege you have on this column, currently not available (String)
**Examples** **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 optional keyword `EXTENDED` currently has no effect, it only exists for MySQL compatibility.
The statement produces a result table with the following structure: The statement produces a result table with the following structure:
- table - The name of the table. (String) - `table` - The name of the table. (String)
- non_unique - Always `1` as ClickHouse does not support uniqueness constraints. (UInt8) - `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) - `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) - `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) - `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)) - `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) - `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)) - `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)) - `packed` - Always `NULL` because ClickHouse does not support packed indexes (like MySQL). (Nullable(String))
- null - Currently unused - `null` - Currently unused
- index_type - The index type, e.g. `PRIMARY`, `MINMAX`, `BLOOM_FILTER` etc. (String) - `index_type` - The index type, e.g. `PRIMARY`, `MINMAX`, `BLOOM_FILTER` etc. (String)
- comment - Additional information about the index, currently always `''` (empty string). (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) - `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) - `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) - `expression` - For a data skipping index, the index expression. For a primary key index: `''` (empty string). (String)
**Examples** **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(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(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) \ 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); 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; size_t position = 0;
for (const auto & column : columns) for (const auto & column : columns)
{ {
@ -161,7 +149,7 @@ protected:
if (columns_mask[src_index++]) if (columns_mask[src_index++])
res_columns[res_index++]->insert(column.name); res_columns[res_index++]->insert(column.name);
if (columns_mask[src_index++]) 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++]) if (columns_mask[src_index++])
res_columns[res_index++]->insert(position); res_columns[res_index++]->insert(position);

View File

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

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;