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

Adding pipes and grep|like in output #361

Closed
matteoredaelli opened this issue Oct 18, 2019 · 4 comments
Closed

Adding pipes and grep|like in output #361

matteoredaelli opened this issue Oct 18, 2019 · 4 comments

Comments

@matteoredaelli
Copy link

It would be nice to have a "grep" or "like" function for filtering the output

Something like

!tables | grep "^DWH_" or !tables | like 'DWH_%'
!columns | grep "DESC" or !columns | like '%DESCR%'

Thanks
Matteo

@julianhyde
Copy link
Owner

An alternative is to use SQL. E.g. in Calcite,

> select * from "metadata".TABLES where "tableName" like '%S';
+----------+------------+-----------+--------------+---------+---------+-----------+----------+------------------------+---------------+
| tableCat | tableSchem | tableName |  tableType   | remarks | typeCat | typeSchem | typeName | selfReferencingColName | refGeneration |
+----------+------------+-----------+--------------+---------+---------+-----------+----------+------------------------+---------------+
|          | metadata   | COLUMNS   | SYSTEM TABLE |         |         |           |          |                        |               |
|          | metadata   | TABLES    | SYSTEM TABLE |         |         |           |          |                        |               |
+----------+------------+-----------+--------------+---------+---------+-----------+----------+------------------------+---------------+
2 rows selected (0.186 seconds)

@snuyanzin
Copy link
Collaborator

snuyanzin commented Oct 18, 2019

it even works for !tables without like, grep, e.g.

> !tables %MP%
+-----------+-------------+--------------+------------+---------+----------+------------+-----------+---------------------------+----------------+
| TABLE_CAT | TABLE_SCHEM |  TABLE_NAME  | TABLE_TYPE | REMARKS | TYPE_CAT | TYPE_SCHEM | TYPE_NAME | SELF_REFERENCING_COL_NAME | REF_GENERATION |
+-----------+-------------+--------------+------------+---------+----------+------------+-----------+---------------------------+----------------+
|           | SALES       | EMPS         | TABLE      |         |          |            |           |                           |                |
|           | SALES       | SAMPLE_SALES | TABLE      |         |          |            |           |                           |                |
+-----------+-------------+--------------+------------+---------+----------+------------+-----------+---------------------------+----------------+

while without filter

> !tables 
+-----------+-------------+--------------+--------------+---------+----------+------------+-----------+---------------------------+----------------+
| TABLE_CAT | TABLE_SCHEM |  TABLE_NAME  |  TABLE_TYPE  | REMARKS | TYPE_CAT | TYPE_SCHEM | TYPE_NAME | SELF_REFERENCING_COL_NAME | REF_GENERATION |
+-----------+-------------+--------------+--------------+---------+----------+------------+-----------+---------------------------+----------------+
|           | SALES       | DEPTS        | TABLE        |         |          |            |           |                           |                |
|           | SALES       | EMPS         | TABLE        |         |          |            |           |                           |                |
|           | SALES       | SAMPLE_SALES | TABLE        |         |          |            |           |                           |                |
|           | SALES       | SDEPTS       | TABLE        |         |          |            |           |                           |                |
|           | metadata    | COLUMNS      | SYSTEM TABLE |         |          |            |           |                           |                |
|           | metadata    | TABLES       | SYSTEM TABLE |         |          |            |           |                           |                |
+-----------+-------------+--------------+--------------+---------+----------+------------+-----------+---------------------------+----------------+

in case of !columns it also filters however it tries to filter by TABLE_NAME column and may be that is what makes sense to fix

@matteoredaelli
Copy link
Author

Thanks!

Yes I agree with you about fixing !columns

@snuyanzin
Copy link
Collaborator

merged as 32c974a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants