简体   繁体   中英

Shell Hive - Identify a column in entire Hive Database

The below code not go in loop if I change first line to hive -S -e 'show databases like 'abc_xyz%' '| Can you please help to fix this issue?`

hive -S -e 'show databases'|
    while read database
    do
       eval "hive -S -e 'show tables in $database'"|
       while read line
       do
    if eval "hive -S -e 'describe $database.$line'"| grep -q "<column_name>"; then
      output="Required table name: $database.$line"'\n';
    else
    output=""'\n';
    
    fi
    echo -e "$output"
     done
    done```

Wildcards in the show databases command pattern can only be '*' for any character(s) or '|' for a choice for Hive < 4.0.0.

For example like this:

show databases like 'abc_xyz*|bcd_xyz*'

SQL-style patterns '%' for any character(s), and '_' for a single character work only since Hive 4.0.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM