简体   繁体   中英

Sqoop + Postgresql: how to prevent quotes around table name

I am trying to import a table from Postgresql to a Parquet file on HDFS.

Here is what I do:

sqoop import \
    --connect "jdbc:postgresql://pg.foo.net:5432/bar" \
    --username user_me --password $PASSWORD \
    --table foo.bar \
    --target-dir /user/me/bar \
    --as-parquetfile

and I get

INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM "foo.bar" AS t LIMIT 1
ERROR manager.SqlManager: Error executing statement: org.postgresql.util.PSQLException: ERROR: relation "foo.bar" does not exist

SELECT t.* FROM "foo.bar" AS t LIMIT 1 does not work indeed, but SELECT t.* FROM foo.bar AS t LIMIT 1 does. So the problem is that table name is quoted. I tried supplying --table argument different ways, but with no effect.

How do I work it around?

EDIT

As the docs you linked state, there is a --schema argument. For some reason it is not mentioned in sqoop help import .

Another weird thing is that

--table bar --schema foo

still does not work, but

--table bar -- --schema foo

does.

Anyway, it works now. Thanks for linking the relevant docs section!

The table name is bar , foo is the name of the schema. According to the docs you should do it like:

sqoop import \
    (...)
    --table bar \
    --schema foo
    (...)

According to the documentation you need to specify the schema separately:

sqoop import \
    --connect "jdbc:postgresql://pg.foo.net:5432/bar" \
    --username user_me --password $PASSWORD \
    --table bar \
    --schema foo \
    --target-dir /user/me/bar \
    --as-parquetfile

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