let table hwctest has 2 columns as below,
+--------------------------+------------+----------+
| col_name | data_type | comment |
+--------------------------+------------+----------+
| col1 | string | |
| col2 | string | |
| dt | date | |
| | NULL | NULL |
| # Partition Information | NULL | NULL |
| # col_name | data_type | comment |
| dt | date | |
+--------------------------+------------+----------+
getting column name from metadata and stored in temp var,
beeline -u "jdbcurl" --showHeader=false --outputformat=csv2 -e "SELECT COLUMN_NAME FROM sys.COLUMNS_V2 c JOIN sys.TBLS a ON c.CD_ID=a.TBL_ID where a.TBL_NAME='hwctest'" | tr "\n" "," > tmp
a=$(cat tmp)
Passing col names as variable,
beeline -u "jdbcurl" --hivevar colName=${a%?}
.....
0: jdbc:hive2://c2757-node3.coelab.cloudera.c> select case when array_contains(split('${colName}',','),'col1') then 1 else 0
. . . . . . . . . . . . . . . . . . . . . . .> end as type
.....
INFO : Executing command(queryId=hive_20220218082727_46d036f4-7667-485a-a2c9-c5be158292d4): select case when array_contains(split('col1,col2',','),'col1') then 1 else 0
end as type
+-------+
| type |
+-------+
| 1 |
+-------+
replace the value col1 in your case.