alamb opened a new pull request #9866:
URL: https://github.com/apache/arrow/pull/9866


   (built on https://github.com/apache/arrow/pull/9840, so draft until that is 
merged)
   
   # Rationale
   Accessing the list of columns via `select * from information_schema.columns` 
(introduced in https://github.com/apache/arrow/pull/9840) is a lot to type
   
   See the doc for background: 
https://docs.google.com/document/d/12cpZUSNPqVH9Z0BBx6O8REu7TFqL-NPPAYCUPpDls1k/edit#
   
   # Proposal
   
   Add support for `SHOW COLUMNS FROM <table>` command.
   
   Following the MySQL syntax supported by sqlparser: 
https://dev.mysql.com/doc/refman/8.0/en/show-columns.html
   
   # Example Use
   
   Setup:
   ```
   echo "1,Foo,44.9" > /tmp/table.csv
   echo "2,Bar,22.1" >> /tmp/table.csv
   cargo run --bin datafusion-cli
   ```
   
   Then run :
   
   ```
   > CREATE EXTERNAL TABLE t(a int, b varchar, c float)
   STORED AS CSV
   LOCATION '/tmp/table.csv';
   > 0 rows in set. Query took 0 seconds.
   
   show columns from t;
   show columns from t;
   
+---------------+--------------+------------+-------------+-----------+-------------+
   | table_catalog | table_schema | table_name | column_name | data_type | 
is_nullable |
   
+---------------+--------------+------------+-------------+-----------+-------------+
   | datafusion    | public       | t          | a           | Int32     | NO   
       |
   | datafusion    | public       | t          | b           | Utf8      | NO   
       |
   | datafusion    | public       | t          | c           | Float32   | NO   
       |
   
+---------------+--------------+------------+-------------+-----------+-------------+
   3 row in set. Query took 0 seconds.
   ```
   
   Note that the identifiers are case sensitive (which is a more general
   problem that affects all name resolution). Ideally this should also work:
   
   ```
   > show columns from T;
   Plan("Unknown relation for SHOW COLUMNS: T")
   
   > select * from T;
   Plan("Table or CTE with name \'T\' not found")
   ```
   
   # Commentary
   This is the sister PR to `SHOW TABLES` here:  
https://github.com/apache/arrow/pull/9847


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to