Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: information_schema.columns doesn't work #10271

Closed
2 tasks done
haydenflinner opened this issue Feb 28, 2023 · 8 comments
Closed
2 tasks done

bug: information_schema.columns doesn't work #10271

haydenflinner opened this issue Feb 28, 2023 · 8 comments
Labels
C-bug Category: something isn't working

Comments

@haydenflinner
Copy link

haydenflinner commented Feb 28, 2023

Search before asking

  • I had searched in the issues and found no similar issues.

Version

v0.9.55-nightly (also tried 0.9.56)

What's Wrong?

#4659 doesn't work anymore, at least the columns table

How to Reproduce?

MySQL [trc]> select * from information_schema.columns WHERE table_name= 'fct_server' limit 5;
ERROR 1105 (HY000): Code: 1065, displayText = column doesn't exist.
MySQL [trc]> select * from information_schema.tables;                                                                                                                                                                                                                                                                                                                                                                                       
+--------------------+--------------------+-------------------------------------------+------------+--------------------+-------------------------------+-----------+-------------+--------------+---------------+                                                                                                                                                                                                                          
| table_catalog      | table_schema       | table_name                                | table_type | engine             | create_time                   | drop_time | data_length | index_length | table_comment |                                                                                                                                                                                                                          
+--------------------+--------------------+-------------------------------------------+------------+--------------------+-------------------------------+-----------+-------------+--------------+---------------+                                                                                                                                                                                                                          
| system             | system             | users                                     | BASE TABLE | SystemUsers        | 2023-02-28 13:22:34.725 +0000 | NULL      |        NULL |         NULL |               |                                                                                                                                                                                                                          
...
| trc                | trc                | fct_server                                | BASE TABLE | VIEW               | 2023-02-28 19:41:26.669 +0000 | NULL      |        NULL |         NULL |               |
+--------------------+--------------------+-------------------------------------------+------------+--------------------+-------------------------------+-----------+-------------+--------------+---------------+

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
@haydenflinner haydenflinner added the C-bug Category: something isn't working label Feb 28, 2023
@BohuTANG
Copy link
Member

BohuTANG commented Mar 1, 2023

cc @TCeason

@TCeason
Copy link
Collaborator

TCeason commented Mar 1, 2023

I can query in my local

'root'@mysqldb 08:38:52 [information_schema]> select * from information_schema.columns WHERE table_name= 'fct_server' limit 5;
Empty set (0.21 sec)
Read 247 rows, 28.60 KiB in 0.158 sec., 1.56 thousand rows/sec., 181.06 KiB/sec.

'root'@mysqldb 08:40:06 [information_schema]> select version();
+-------------------------------------------------------------------------------------+
| version()                                                                           |
+-------------------------------------------------------------------------------------+
| 8.0.26-v0.8.145-nightly-46491e0(rust-1.68.0-nightly-2023-02-23T07:20:55.219302423Z) |
+-------------------------------------------------------------------------------------+
1 row in set (0.03 sec)

'root'@mysqldb 08:40:12 [information_schema]> desc information_schema.columns;
+--------------------------+------------------+------+---------+-------+
| Field                    | Type             | Null | Default | Extra |
+--------------------------+------------------+------+---------+-------+
| table_catalog            | VARCHAR          | NO   | ""      |       |
| table_schema             | VARCHAR          | NO   | ""      |       |
| table_name               | VARCHAR          | NO   | ""      |       |
| column_name              | VARCHAR          | NO   | ""      |       |
| ordinal_position         | TINYINT UNSIGNED | NO   | 0       |       |
| column_default           | NULL             | NO   | NULL    |       |
| column_comment           | NULL             | NO   | NULL    |       |
| column_key               | NULL             | NO   | NULL    |       |
| is_nullable              | VARCHAR          | NO   | ""      |       |
| data_type                | VARCHAR          | NO   | ""      |       |
| column_type              | VARCHAR          | NO   | ""      |       |
| character_maximum_length | NULL             | NO   | NULL    |       |
| character_octet_length   | NULL             | NO   | NULL    |       |
| numeric_precision        | NULL             | NO   | NULL    |       |
| numeric_precision_radix  | NULL             | NO   | NULL    |       |
| numeric_scale            | NULL             | NO   | NULL    |       |
| datetime_precision       | NULL             | NO   | NULL    |       |
| character_set_catalog    | NULL             | NO   | NULL    |       |
| character_set_schema     | NULL             | NO   | NULL    |       |
| character_set_name       | NULL             | NO   | NULL    |       |
| collation_catalog        | NULL             | NO   | NULL    |       |
| collation_schema         | NULL             | NO   | NULL    |       |
| collation_name           | NULL             | NO   | NULL    |       |
| domain_catalog           | NULL             | NO   | NULL    |       |
| domain_schema            | NULL             | NO   | NULL    |       |
| domain_name              | NULL             | NO   | NULL    |       |
| extra                    | NULL             | NO   | NULL    |       |
+--------------------------+------------------+------+---------+-------+
27 rows in set (0.07 sec)
Read 0 rows, 0.00 B in 0.022 sec., 0 rows/sec., 0.00 B/sec.

Please provide result of show settings

@TCeason
Copy link
Collaborator

TCeason commented Mar 1, 2023

And also provide result of show create table information_schema.columns;

'root'@mysqldb 08:43:58 [test]> show create table information_schema.columns;
+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table   | Create Table                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| columns | CREATE TABLE `columns` (

) ENGINE=VIEW QUERY='SELECT
            database AS table_catalog,
            database AS table_schema,
            table AS table_name,
            name AS column_name,
            1 AS ordinal_position,
            NULL AS column_default,
            NULL AS column_comment,
            NULL AS column_key,
            is_nullable AS is_nullable,
            data_type AS data_type,
            data_type AS column_type,
            NULL AS character_maximum_length,
            NULL AS character_octet_length,
            NULL AS numeric_precision,
            NULL AS numeric_precision_radix,
            NULL AS numeric_scale,
            NULL AS datetime_precision,
            NULL AS character_set_catalog,
            NULL AS character_set_schema,
            NULL AS character_set_name,
            NULL AS collation_catalog,
            NULL AS collation_schema,
            NULL AS collation_name,
            NULL AS domain_catalog,
            NULL AS domain_schema,
            NULL AS domain_name,
            NULL AS extra
        FROM system.columns;' |
+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.06 sec)
Read 0 rows, 0.00 B in 0.019 sec., 0 rows/sec., 0.00 B/sec.

'root'@mysqldb 08:44:42 [test]> show settings;
+------------------------------------+-------------+-------------+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+
| name                               | value       | default     | level   | description                                                                                                                                                                                                                             | type   |
+------------------------------------+-------------+-------------+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+
| collation                          | binary      | binary      | SESSION | Char collation, support "binary" "utf8" default value: binary                                                                                                                                                                           | String |
| enable_async_insert                | 0           | 0           | SESSION | Whether the client open async insert mode, default value: 0.                                                                                                                                                                            | UInt64 |
| enable_bushy_join                  | 0           | 0           | SESSION | Enable generating bushy join plan in optimizer                                                                                                                                                                                          | UInt64 |
| enable_cbo                         | 1           | 1           | SESSION | If enable cost based optimization, default value: 1.                                                                                                                                                                                    | UInt64 |
| enable_distributed_eval_index      | 1           | 1           | SESSION | If enable distributed eval index, default value: 1                                                                                                                                                                                      | UInt64 |
| enable_new_processor_framework     | 1           | 1           | SESSION | Enable new processor framework if value != 0, default value: 1.                                                                                                                                                                         | UInt64 |
| enable_planner_v2                  | 1           | 1           | SESSION | Enable planner v2 by setting this variable to 1, default value: 1.                                                                                                                                                                      | UInt64 |
| enable_query_result_cache          | 0           | 0           | SESSION | Enable the cache result of each query. It's disabled by default.                                                                                                                                                                        | UInt64 |
| flight_client_timeout              | 60          | 60          | SESSION | Max duration the flight client request is allowed to take in seconds. By default, it is 60 seconds.                                                                                                                                     | UInt64 |
| group_by_two_level_threshold       | 10000       | 10000       | SESSION | The threshold of keys to open two-level aggregation, default value: 10000.                                                                                                                                                              | UInt64 |
| input_read_buffer_size             | 1048576     | 1048576     | SESSION | The size of buffer in bytes for input with format. By default, it is 1MB.                                                                                                                                                               | UInt64 |
| load_file_metadata_expire_hours    | 168         | 168         | SESSION | How many hours will the COPY file metadata expired in the metasrv, default value: 24*7=7days                                                                                                                                            | UInt64 |
| max_block_size                     | 65536       | 65536       | SESSION | Maximum block size for reading, default value: 65536.                                                                                                                                                                                   | UInt64 |
| max_execute_time                   | 0           | 0           | SESSION | The maximum query execution time. it means no limit if the value is zero. default value: 0.                                                                                                                                             | UInt64 |
| max_inlist_to_or                   | 3           | 3           | SESSION | Max size in inlist expression that will convert to or combinator, default value: 3.                                                                                                                                                     | UInt64 |
| max_memory_usage                   | 13201388339 | 13201388339 | SESSION | The maximum memory usage for processing single query, in bytes. By default the value is determined automatically.                                                                                                                       | UInt64 |
| max_result_cache_bytes             | 1048576     | 1048576     | SESSION | The maximum bytes of the result cache for one query, default: 1048576 bytes (1MB).                                                                                                                                                      | UInt64 |
| max_result_rows                    | 0           | 0           | SESSION | Auto limit max result rows if user not specify the limit, default is 0 means no limit                                                                                                                                                   | UInt64 |
| max_storage_io_requests            | 8           | 8           | SESSION | The maximum number of concurrent IO requests. By default the value is determined automatically.                                                                                                                                         | UInt64 |
| max_threads                        | 8           | 8           | SESSION | The maximum number of threads to execute the request. By default the value is determined automatically.                                                                                                                                 | UInt64 |
| parquet_uncompressed_buffer_size   | 2097152     | 2097152     | SESSION | Parquet decompresses buffer size. default: 2MB                                                                                                                                                                                          | UInt64 |
| prefer_broadcast_join              | 1           | 1           | SESSION | If enable broadcast join, default value: 1                                                                                                                                                                                              | UInt64 |
| quoted_ident_case_sensitive        | 1           | 1           | SESSION | Case sensitivity of quoted identifiers, default value: 1 (aka case-sensitive).                                                                                                                                                          | UInt64 |
| result_cache_ttl                   | 300         | 300         | SESSION | Time-to-live of query result cache, default: 300 seconds (5 minutes).                                                                                                                                                                   | UInt64 |
| retention_period                   | 12          | 12          | SESSION | The retention_period in hours. By default the value is 12 hours.                                                                                                                                                                        | UInt64 |
| sandbox_tenant                     |             |             | SESSION | Inject a custom sandbox_tenant into this session, it's only for testing purpose and take effect when the internal_enable_sandbox_tenant is on                                                                                           | String |
| sql_dialect                        | PostgreSQL  | PostgreSQL  | SESSION | SQL dialect, support "PostgreSQL" "MySQL" and "Hive", default value: "PostgreSQL".                                                                                                                                                      | String |
| storage_fetch_part_num             | 2           | 2           | SESSION | The max number of part each read cycle.                                                                                                                                                                                                 | UInt64 |
| storage_io_max_page_bytes_for_read | 524288      | 524288      | SESSION | The maximum bytes of one IO request to read. Default the value is 512KB                                                                                                                                                                 | UInt64 |
| storage_io_min_bytes_for_seek      | 48          | 48          | SESSION | If the distance between two IO ranges to be read in one file is less than storage_io_min_bytes_for_seek, then Databend sequentially reads a range of file that contains both ranges, thus avoiding extra seek. Default value is 48Bytes | UInt64 |
| storage_read_buffer_size           | 1048576     | 1048576     | SESSION | The size of buffer in bytes for buffered reader of dal. By default, it is 1MB.                                                                                                                                                          | UInt64 |
| timezone                           | UTC         | UTC         | SESSION | Timezone, default value: "UTC".                                                                                                                                                                                                         | String |
| tolerate_inconsistent_result_cache | 0           | 0           | SESSION | Tolerate inconsistent result cache. It's disabled by default.                                                                                                                                                                           | UInt64 |
| unquoted_ident_case_sensitive      | 0           | 0           | SESSION | Case sensitivity of unquoted identifiers, default value: 0 (aka case-insensitive).                                                                                                                                                      | UInt64 |
| wait_for_async_insert              | 1           | 1           | SESSION | Whether the client wait for the reply of async insert, default value: 1.                                                                                                                                                                | UInt64 |
| wait_for_async_insert_timeout      | 100         | 100         | SESSION | The timeout in seconds for waiting for processing of async insert, default value: 100.                                                                                                                                                  | UInt64 |
+------------------------------------+-------------+-------------+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+
36 rows in set (0.09 sec)
Read 36 rows, 5.85 KiB in 0.018 sec., 1.97 thousand rows/sec., 321.08 KiB/sec.

@haydenflinner
Copy link
Author

One difference I see is the version()s we're using: 8.0.26-v0.9.56-nightly-425cad1(rust-1.68.0-nightly-2023-02-28T16:26:09.612256076Z

It's also interesting but unrelated that the default dialect is Postgres rather than MySql.

MySQL [trc]> show settings;
+---------------------------------------+--------------+--------------+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+
| name                                  | value        | default      | level   | description                                                                                                                                                                                                                                                                                   | type   |
+---------------------------------------+--------------+--------------+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+
| collation                             | binary       | binary       | SESSION | Char collation, support "binary" "utf8" default value: binary                                                                                                                                                                                                                                 | String |
| enable_async_insert                   | 0            | 0            | SESSION | Whether the client open async insert mode, default value: 0.                                                                                                                                                                                                                                  | UInt64 |
| enable_bushy_join                     | 0            | 0            | SESSION | Enable generating bushy join plan in optimizer                                                                                                                                                                                                                                                | UInt64 |
| enable_cbo                            | 1            | 1            | SESSION | If enable cost based optimization, default value: 1.                                                                                                                                                                                                                                          | UInt64 |
| enable_distributed_eval_index         | 1            | 1            | SESSION | If enable distributed eval index, default value: 1                                                                                                                                                                                                                                            | UInt64 |
| enable_new_processor_framework        | 1            | 1            | SESSION | Enable new processor framework if value != 0, default value: 1.                                                                                                                                                                                                                               | UInt64 |
| enable_planner_v2                     | 1            | 1            | SESSION | Enable planner v2 by setting this variable to 1, default value: 1.                                                                                                                                                                                                                            | UInt64 |
| enable_query_result_cache             | 0            | 0            | SESSION | Enable the query result caching of SQL queries in Databend. When this setting is enabled, Databend will store the results of queries in storage. This can improve query performance by reducing the amount of time required to re-execute the same query multiple times. Default is disabled. | UInt64 |
| flight_client_timeout                 | 60           | 60           | SESSION | Max duration the flight client request is allowed to take in seconds. By default, it is 60 seconds.                                                                                                                                                                                           | UInt64 |
| group_by_two_level_threshold          | 20000        | 20000        | SESSION | The threshold of keys to open two-level aggregation, default value: 20000.                                                                                                                                                                                                                    | UInt64 |
| hide_options_in_show_create_table     | 1            | 1            | SESSION | Ignore options while rendering the result of show create table.                                                                                                                                                                                                                               | UInt64 |
| input_read_buffer_size                | 1048576      | 1048576      | SESSION | The size of buffer in bytes for input with format. By default, it is 1MB.                                                                                                                                                                                                                     | UInt64 |
| load_file_metadata_expire_hours       | 168          | 168          | SESSION | How many hours will the COPY file metadata expired in the metasrv, default value: 24*7=7days                                                                                                                                                                                                  | UInt64 |
| max_block_size                        | 65536        | 65536        | SESSION | Maximum block size for reading, default value: 65536.                                                                                                                                                                                                                                         | UInt64 |
| max_execute_time                      | 0            | 0            | SESSION | The maximum query execution time. it means no limit if the value is zero. default value: 0.                                                                                                                                                                                                   | UInt64 |
| max_inlist_to_or                      | 3            | 3            | SESSION | Max size in inlist expression that will convert to or combinator, default value: 3.                                                                                                                                                                                                           | UInt64 |
| max_memory_usage                      | 216297291776 | 216297291776 | SESSION | The maximum memory usage for processing single query, in bytes. By default the value is determined automatically.                                                                                                                                                                             | UInt64 |
| max_result_rows                       | 0            | 0            | SESSION | Auto limit max result rows if user not specify the limit, default is 0 means no limit                                                                                                                                                                                                         | UInt64 |
| max_storage_io_requests               | 64           | 64           | SESSION | The maximum number of concurrent IO requests. By default the value is determined automatically.                                                                                                                                                                                               | UInt64 |
| max_threads                           | 28           | 28           | SESSION | The maximum number of threads to execute the request. By default the value is determined automatically.                                                                                                                                                                                       | UInt64 |
| parquet_uncompressed_buffer_size      | 2097152      | 2097152      | SESSION | Parquet decompresses buffer size. default: 2MB                                                                                                                                                                                                                                                | UInt64 |
| prefer_broadcast_join                 | 1            | 1            | SESSION | If enable broadcast join, default value: 1                                                                                                                                                                                                                                                    | UInt64 |
| query_result_cache_allow_inconsistent | 0            | 0            | SESSION | Controls whether inconsistent cached results can be used for queries. When this setting is set to TRUE, Databend will use cached results even if they may be inconsistent due to changes in the underlying data. Default is FALSE (disabled).                                                 | UInt64 |
| query_result_cache_max_bytes          | 1048576      | 1048576      | SESSION | The maximum bytes of the query result cache for one query, default: 1048576 bytes (1MB).                                                                                                                                                                                                      | UInt64 |
| query_result_cache_ttl_secs           | 300          | 300          | SESSION | The time-to-live (TTL) for cached query results, in seconds. Once the TTL for a cached result has expired, the result is considered stale and will not be used for new queries. Default: 300 seconds (5 minutes).                                                                             | UInt64 |
| quoted_ident_case_sensitive           | 1            | 1            | SESSION | Case sensitivity of quoted identifiers, default value: 1 (aka case-sensitive).                                                                                                                                                                                                                | UInt64 |
| retention_period                      | 12           | 12           | SESSION | The retention_period in hours. By default the value is 12 hours.                                                                                                                                                                                                                              | UInt64 |
| sandbox_tenant                        |              |              | SESSION | Inject a custom sandbox_tenant into this session, it's only for testing purpose and take effect when the internal_enable_sandbox_tenant is on                                                                                                                                                 | String |
| sql_dialect                           | PostgreSQL   | PostgreSQL   | SESSION | SQL dialect, support "PostgreSQL" "MySQL" and "Hive", default value: "PostgreSQL".                                                                                                                                                                                                            | String |
| storage_fetch_part_num                | 2            | 2            | SESSION | The max number of part each read cycle.                                                                                                                                                                                                                                                       | UInt64 |
| storage_io_max_page_bytes_for_read    | 524288       | 524288       | SESSION | The maximum bytes of one IO request to read. Default the value is 512KB                                                                                                                                                                                                                       | UInt64 |
| storage_io_min_bytes_for_seek         | 48           | 48           | SESSION | If the distance between two IO ranges to be read in one file is less than storage_io_min_bytes_for_seek, then Databend sequentially reads a range of file that contains both ranges, thus avoiding extra seek. Default value is 48Bytes                                                       | UInt64 |
| storage_read_buffer_size              | 1048576      | 1048576      | SESSION | The size of buffer in bytes for buffered reader of dal. By default, it is 1MB.                                                                                                                                                                                                                | UInt64 |
| timezone                              | UTC          | UTC          | SESSION | Timezone, default value: "UTC".                                                                                                                                                                                                                                                               | String |
| unquoted_ident_case_sensitive         | 0            | 0            | SESSION | Case sensitivity of unquoted identifiers, default value: 0 (aka case-insensitive).                                                                                                                                                                                                            | UInt64 |
| wait_for_async_insert                 | 1            | 1            | SESSION | Whether the client wait for the reply of async insert, default value: 1.                                                                                                                                                                                                                      | UInt64 |
| wait_for_async_insert_timeout         | 100          | 100          | SESSION | The timeout in seconds for waiting for processing of async insert, default value: 100.                                                                                                                                                                                                        | UInt64 |
+---------------------------------------+--------------+--------------+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+
37 rows in set (0.01 sec)
MySQL [trc]> desc information_schema.columns;
+--------------------------+------------------+------+---------+-------+
| Field                    | Type             | Null | Default | Extra |
+--------------------------+------------------+------+---------+-------+
| table_catalog            | VARCHAR          | NO   | ""      |       |
| table_schema             | VARCHAR          | NO   | ""      |       |
| table_name               | VARCHAR          | NO   | ""      |       |
| column_name              | VARCHAR          | NO   | ""      |       |
| ordinal_position         | TINYINT UNSIGNED | NO   | 0       |       |
| column_default           | NULL             | NO   | NULL    |       |
| column_comment           | NULL             | NO   | NULL    |       |
| column_key               | NULL             | NO   | NULL    |       |
| is_nullable              | VARCHAR          | NO   | ""      |       |
| data_type                | VARCHAR          | NO   | ""      |       |
| column_type              | VARCHAR          | NO   | ""      |       |
| character_maximum_length | NULL             | NO   | NULL    |       |
| character_octet_length   | NULL             | NO   | NULL    |       |
| numeric_precision        | NULL             | NO   | NULL    |       |
| numeric_precision_radix  | NULL             | NO   | NULL    |       |
| numeric_scale            | NULL             | NO   | NULL    |       |
| datetime_precision       | NULL             | NO   | NULL    |       |
| character_set_catalog    | NULL             | NO   | NULL    |       |
| character_set_schema     | NULL             | NO   | NULL    |       |
| character_set_name       | NULL             | NO   | NULL    |       |
| collation_catalog        | NULL             | NO   | NULL    |       |
| collation_schema         | NULL             | NO   | NULL    |       |
| collation_name           | NULL             | NO   | NULL    |       |
| domain_catalog           | NULL             | NO   | NULL    |       |
| domain_schema            | NULL             | NO   | NULL    |       |
| domain_name              | NULL             | NO   | NULL    |       |
| extra                    | NULL             | NO   | NULL    |       |
+--------------------------+------------------+------+---------+-------+
27 rows in set (0.01 sec)
MySQL [trc]> show create table information_schema.columns;
+---------+-----------------------------------------+
| Table   | Create Table                            |
+---------+-----------------------------------------+
| columns | CREATE TABLE `columns` (

) ENGINE=VIEW |
+---------+-----------------------------------------+
1 row in set (0.01 sec)

@TCeason
Copy link
Collaborator

TCeason commented Mar 2, 2023

It's ok on my local with commit version 425cad1.

And if query with a not exists column, databend will have some other error hints like this example:

'root'@mysqldb 07:58:37 [trc]> select version();
+------------------------------------------------------------------------------------+
| version()                                                                          |
+------------------------------------------------------------------------------------+
| 8.0.26-v0.9.56-nightly-425cad1(rust-1.68.0-nightly-2023-03-01T23:49:50.953368995Z) |
+------------------------------------------------------------------------------------+
1 row in set (0.05 sec)

'root'@mysqldb 07:58:43 [trc]> select * from information_schema.columns WHERE table_name = 'fct_server' limit 5;
Empty set (0.23 sec)
Read 253 rows, 29.27 KiB in 0.175 sec., 1.44 thousand rows/sec., 166.86 KiB/sec.

'root'@mysqldb 07:58:47 [trc]> select * from information_schema.columns WHERE table_namecc = 'fct_server' limit 5;
ERROR 1105 (HY000): Code: 1065, displayText = error: 
  --> SQL:1:48
  |
1 | select * from information_schema.columns WHERE table_namecc = 'fct_server' limit 5
  |                                                ^^^^^^^^^^^^ column doesn't exist

.

So if you can still reproduce please also provide the query log.

@TCeason
Copy link
Collaborator

TCeason commented Mar 2, 2023

By the way, information_schema.columns is a view of system.columns.

https://github.com/datafuselabs/databend/blob/425cad12a9fdd46c0ff24615a6a28ea2ce0e919e/src/query/storages/information-schema/src/columns_table.rs

 'root'@mysqldb 08:04:28 [system]> select * from system.columns limit 1;
+------+----------+---------------------+--------+-----------+--------------+--------------------+-------------+---------+
| name | database | table               | type   | data_type | default_kind | default_expression | is_nullable | comment |
+------+----------+---------------------+--------+-----------+--------------+--------------------+-------------+---------+
| name | system   | malloc_stats_totals | String | VARCHAR   |              |                    | NO          |         |
+------+----------+---------------------+--------+-----------+--------------+--------------------+-------------+---------+

@sundy-li
Copy link
Member

sundy-li commented Mar 2, 2023

Do you have any view in the catalog? You can drop the view and recreate them.

@haydenflinner
Copy link
Author

One thing I've noticed is that if I USE abc (another db in my instance) I get a different error message, which doesn't seem right:

MySQL [abc]> select * from system.columns limit 1;
ERROR 1105 (HY000): Code: 1025, displayText = Unknown table 'dim_x_snapshot'.
MySQL [abc]> select * from information_schema.columns WHERE table_name= 'fct_server' limit 5;
ERROR 1105 (HY000): Code: 1025, displayText = Unknown table 'dim_x_snapshot'.

@sundy-li Good idea, you lead me to the fix! Creating a view that doesn't work is perfectly valid, it doesn't error until you try to SELECT from it. When I delete my views that are bad like that, everything is good. Here is an example of one of my bad views:

MySQL [trc]> select * from fct_lolbad limit 1;
ERROR 1105 (HY000): Code: 1065, displayText = error: 
  --> SQL:1:46
  |
1 | select * from fct_lolbad limit 1
  |                                                column doesn't exist

I ran drop view fct_lolbad and voila, my information_schema.columns is fixed! Thank you!

@sundy-li sundy-li closed this as completed Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants