Support Questions

Find answers, ask questions, and share your expertise

Newline character as delimiter in Phoenix Bulk load

Hi,

I have a requirement where i need to load all the columns of file in a single column in table. I am thinking to make newline as delimiter to insert all columns of file in a single column of Phoenix.

I tried various options to pass newline character as delimiter but none of it worked so far :

./psql.py -d $'/n' -t POC.SINGLE_LINE /export/home/KBM_HOU/pkumar/test_newdelimiter.csv

./psql.py -d $'//n' -t POC.SINGLE_LINE /export/home/KBM_HOU/pkumar/test_newdelimiter.csv

./psql.py -d '/n' -t POC.SINGLE_LINE /export/home/KBM_HOU/pkumar/test_newdelimiter.csv

./psql.py -d '//n' -t POC.SINGLE_LINE /export/home/KBM_HOU/pkumar/test_newdelimiter.csv

I am getting error of invalid single character.

Exception in thread "main" java.lang.IllegalArgumentException: Invalid single character: '//n' at org.apache.phoenix.util.PhoenixRuntime$ExecutionCommand.getCharacter(PhoenixRuntime.java:725) at org.apache.phoenix.util.PhoenixRuntime$ExecutionCommand.parseArgs(PhoenixRuntime.java:655) at org.apache.phoenix.util.PhoenixRuntime.main(PhoenixRuntime.java:215)

Could you let me know how to pass the newline character as the delimiter for any unix file in Phoenix bulk load process.

1 REPLY 1

Hey @Prashant Kumar!
I'm not a specialist in Phoenix, but i made a search here, and it seems that you need to escape your /n (guess with \), otherwise Phoenix will throw an exception.

https://github.com/apache/phoenix/blob/de83b8d5d042098faa294e742525ab84175bb271/phoenix-core/src/mai...

        private static char getCharacter(String s) {
            String unescaped = StringEscapeUtils.unescapeJava(s);
            if (unescaped.length() > 1) {
                throw new IllegalArgumentException("Invalid single character: '" + unescaped + "'");
            }
            return unescaped.charAt(0);
        }

Hope this helps! 🙂