Home > OS >  impala query failed to execute `date` command in shell script
impala query failed to execute `date` command in shell script

Time:01-21

I have below imapala query run on shell script which is throwing error.

date with back quotes `date`

impala-shell -B -i $IMPALA_CON --ssl -q  "use db_test ; select concat(substring(`date`,3,2),substring(`date`,6,2),substring(`date`,9,2)) id from db_test.date_d where `date`<=cast(current_timestamp() as string)" -o $FILE/abc.txt '--output_delimiter=,'

ERROR: ParseException: Syntax error in line 1: select concat(substring(Tue Jan 17 02:18:20 EST 2023,3,2...

CodePudding user response:

date is a shell command, and the backquotes are doing command substitution. You're getting the date substituted in without quotes around it. Try '`date`' instead of just `date` (note the single quotes around the backquotes).

CodePudding user response:

Using impala shell with complexe expression query could generate issuee.

To avoid issues, best practice is to put your queries in a file then use file -f argument instead of -q for query.

-f /path/to/my/dev/my_query_file.sql

my_query_file.sql file must have only sql queries

Hope it will help, this solved me lots of troubles

note : In combination could be quotes syntaxe also ' versus `

  • Related