Skip to content

Trino SHOW COLUMNS only returns the first row #28630

Closed

Description

@maxsbs

Problem description

Since upgrading from Trino v477 to Trino v479, the behavior of SHOW COLUMNS FROM table has changed:

  • In v477, the command show all columns of all tables. Querying the information_schema.columns table shows all columns from all tables.
  • In v479, the command only shows the first column of the table. Querying the information_schema.columns table shows only the first column of each table.

Expected behaviour

Aligned on v477, the command SHOW COLUMNS FROM table show all columns of the table. Querying the information_schema.columns table shows all columns from the table.

Activity

  1. ebyhr commented on Mar 12, 2026

    @ebyhr
    Member

    @maxsbs Could you share the entire steps to reproduce? The config properties (please redact credentials), CREATE TABLE, and etc.

  2. added theissue type on Mar 16, 2026
  3. findepi commented on Mar 16, 2026

    @findepi
    Member

    Since upgrading from Trino v477 to Trino v479

    the #28653 further adds

    The bug was introduced in the bulk column listing feature (commit 1ac1ee1 - "Bulk fetch all columns from all tables in JDBC connectors").

    that code was added in 450 though.

    as @ebyhr already pointed out, it would be great to have steps to reproduce the problem.

  4. maxsbs commented on Mar 16, 2026

    @maxsbs
    Author

    @findepi, @ebyhr we are checking for a reproducible example. What is complex is that we observe this behaviour in several cases but not all. We are trying to isolate the configuration that causes this.

    Additionally, we are using OPA integration with custom policies. We observe the behaviour even with admin users having full access (as part of the policy).

    We will update the ticket once we isolate the problem.

  5. sachinsharma3191 commented on Mar 19, 2026

    @sachinsharma3191

    Repro details (for validating PR #28653):

    Trino versions: regression in v479 vs v477

    Where it happens: JDBC connectors when bulk column listing is used (JdbcClient.getAllTableColumns / DatabaseMetaData.getColumns without a table filter).

    Steps to reproduce

    1. Use any JDBC catalog/connector that supports bulk column listing.
    2. Enable bulk listing for the session:
      SET SESSION .bulk_list_columns = true;
    3. Create at least two tables in the same schema, each with multiple columns (e.g. t1(a,b,c) and t2(x,y,z)).
    4. Run:
      • SELECT table_name, column_name FROM .information_schema.columns WHERE table_schema = '' AND table_name IN ('t1','t2') ORDER BY table_name, ordinal_position;
      • and/or SHOW COLUMNS FROM ..t1; / SHOW COLUMNS FROM ..t2;

    Observed on v479 (bug)

    • The first column of each table after the first one is skipped in the bulk listing result set, so information_schema.columns can end up missing the first column for subsequent tables (and depending on how results are consumed, appear to show only one column per table).

    Expected

    • All columns for all tables are returned (as in v477).

    Root cause (code)

    • In BaseJdbcClient.IterateTableColumns, when switching from one table group to the next, the iterator returns the previous table metadata without processing the current ResultSet row (which is the first column of the new table). On the next computeNext() call, resultSet.next() advances past that unprocessed row, so it is lost.

    PR: #28653

  6. findepi commented on Mar 19, 2026

    @findepi
    Member

    @sachinsharma3191 i tried to follow the steps but failed to reproduce the problem

    I was using Trino with MySQL connector as started by io.trino.plugin.mysql.MySqlQueryRunner#main on current Trino master.

    then

    use mysql.tpch;
    
    set session mysql.bulk_list_columns = true; -- it's the default for MySQL connector anyway
    
    drop table if exists t1;
    create table t1(a int, b int, c int);
    
    drop table if exists t2;
    create table t2(a int, b int, c int);
    
    desc t1;
    desc t2;
    
    select * from information_schema.columns where table_name in ('t1', 't2');
    output is correct
    trino:tpch> use mysql.tpch;
             ->
             -> set session mysql.bulk_list_columns = true;
             ->
             -> drop table if exists t1;
             -> create table t1(a int, b int, c int);
             ->
             -> drop table if exists t2;
             -> create table t2(a int, b int, c int);
             ->
             -> desc t1;
             -> desc t2;
             ->
             -> select * from information_schema.columns where table_name in ('t1', 't2');
    USE
    SET SESSION
    DROP TABLE
    CREATE TABLE
    DROP TABLE
    CREATE TABLE
     Column |  Type   | Extra | Comment
    --------+---------+-------+---------
     a      | integer |       |
     b      | integer |       |
     c      | integer |       |
    (3 rows)
    Query 20260319_133058_00088_ukyqe, FINISHED, 3 nodes
    Splits: 17 total, 17 done (100.00%)
    0.15 [3 rows, 637B] [19 rows/s, 4.12KiB/s]
    
     Column |  Type   | Extra | Comment
    --------+---------+-------+---------
     a      | integer |       |
     b      | integer |       |
     c      | integer |       |
    (3 rows)
    
    Query 20260319_133058_00089_ukyqe, FINISHED, 3 nodes
    Splits: 17 total, 17 done (100.00%)
    0.15 [3 rows, 637B] [19 rows/s, 4.12KiB/s]
    
     table_catalog | table_schema | table_name | column_name | ordinal_position | column_default | is_nullable | data_type
    ---------------+--------------+------------+-------------+------------------+----------------+-------------+-----------
     mysql         | tpch         | t2         | a           |                1 | NULL           | YES         | integer
     mysql         | tpch         | t2         | b           |                2 | NULL           | YES         | integer
     mysql         | tpch         | t2         | c           |                3 | NULL           | YES         | integer
     mysql         | tpch         | t1         | a           |                1 | NULL           | YES         | integer
     mysql         | tpch         | t1         | b           |                2 | NULL           | YES         | integer
     mysql         | tpch         | t1         | c           |                3 | NULL           | YES         | integer
    (6 rows)
    
    Query 20260319_133058_00090_ukyqe, FINISHED, 1 node
    Splits: 1 total, 1 done (100.00%)
    0.17 [6 rows, 396B] [35 rows/s, 2.32KiB/s]
    
    
  7. findepi commented on Mar 19, 2026

    @findepi
    Member

    Note that bulk_list_columns is a hidden property acting as a kill switch for bulk column listing for connectors that do support bulk column listing.

    It is hidden and not supposed to be set by users.
    I used MySQL connector because it does support bulk column listing.

    Some questions to you

    • Are you using one of the connectors that support bulk column listing?
      Or, maybe, are you forcing bulk listing on a connector which does not support it?
    • Which connector are you using?
    • Can you provide exact steps to reproduce the problem? See my previous comment for how this should look like.
  8. sachinsharma3191 commented on Mar 24, 2026

    @sachinsharma3191

    sure let me do the testing as suggested by you

  9. removed their assignment
    on Mar 24, 2026
  10. kjh0623 commented on Jun 21, 2026

    @kjh0623

    We encountered the same symptom on Trino 478 + OPA batched FilterColumns with the Iceberg connector (REST catalog via Gravitino).

    Our Environment
    Trino version: 478
    Connector: Iceberg (non-JDBC) with REST catalog (Gravitino)
    Access Control: OPA with opa.policy.batched-uri configured
    Symptom
    information_schema.columns, DESCRIBE, SHOW COLUMNS, and SELECT * all return only the first column for every Iceberg table. SHOW CREATE TABLE returns all columns correctly (reads Iceberg metadata directly, bypasses information_schema).

    Root Cause (in our case)
    Our OPA batch policy was missing a dedicated FilterColumns handler. When Trino sends a FilterColumns batch request, the payload structure differs from other filter operations:

    {
      "action": {
        "operation": "FilterColumns",
        "filterResources": [{
          "table": {
            "catalogName": "iceberg",
            "schemaName": "lake",
            "tableName": "my_table",
            "columns": ["col1", "col2", ..., "col62"]
          }
        }]
      }
    }
    

    Unlike FilterTables/FilterSchemas (where each resource is a separate item in filterResources[]), FilterColumns sends one resource with a columns array inside. The batch response must return indices into the columns array, not the filterResources array.

    Our generic batch rules only matched on resource.table.catalogName, which matched index 0 (the single table resource) — Trino interpreted this as "allow only the first column."

    Fix (OPA Policy — no Trino code change needed)
    We added this Rego rule to our batch policy:

    # FilterColumns: return all column indices (no column-level ACL)
    batch contains i if {
        some i, _ in input.action.filterResources[0]["table"]["columns"]
        input.action.operation == "FilterColumns"
        any_role  # your allow-all predicate
    }
    

    After applying this + OPA pod restart, information_schema.columns correctly returns all columns.

    Note
    This is a different code path from the JDBC bulk-listing bug described in this issue (BaseJdbcClient.IterateTableColumns), but produces the identical symptom. Users with OPA batch mode enabled should check whether their policy correctly handles the FilterColumns operation's unique payload structure.

    The Trino OPA documentation does mention this corner case at the bottom of the batch mode section, but it's easy to miss.

  11. maxsbs commented on Jun 22, 2026

    @maxsbs
    Author

    Hello @kjh0623,

    Thanks, we figured that out as well thanks to Trino documentation. I thought I had posted a comment on this issue, but this is not the case... Sorry to the community for that.

    Indeed, the corner case fix mentioned in the doc and in your comment solves the problem.

    Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions