0

Hi I have issues querying with swoop and a psaldb

     Sqoop import --connect 'jdbc:postgresql://xx.xx.xxx.xx:xxxxx/database' --query 'select * from report where transact_time = '20160603-00:00:01' and $CONDITIONS' --username uname --target-dir /user/x/data --split-by transact_time

I get the following error :

  Error executing statement: org.postgresql.util.PSQLException: ERROR: syntax error at or near ":"
  Position: 61
  org.postgresql.util.PSQLException: ERROR: syntax error at or near ":"
CodeGeek123
  • 4,341
  • 8
  • 50
  • 79
  • Seems like a quoting issue: `... 'select ... transact_time = '20160603-00:00:01' ... ' ...` (and also, it doesn't seem like a timestamp at all) – pozs Jul 28 '16 at 09:56
  • I tried many combinations of quotes. None work – CodeGeek123 Jul 28 '16 at 10:01
  • If that's in a command line I would try `--query "select ... 'quoted values' ..."` first, and if that's not working somehow, use [escaping](http://stackoverflow.com/questions/3834839/how-to-escape-double-quote-inside-a-double-quote). – pozs Jul 28 '16 at 10:05

1 Answers1

1

You need to issue the query wrapped with double quotes (") as you are using single quotes (') in the query and you will have to use \$CONDITIONS instead of just $CONDITIONS to disallow your shell from treating it as a shell variable.

Try:

--query "select * from report where transact_time = '20160603-00:00:01' and \$CONDITIONS"
Dev
  • 13,492
  • 19
  • 81
  • 174