Hive: why CTAS can't read a file whereas select query can

76 views Asked by At

I have put my file at /hadoop/yarn/local/usercache/root/test_abspath and want to read first line using my UDF. When I ran it using select test('ABCD','ABCD'); I could read the file but when I tried it using Create table as test_tb select test(name,'ABCD') from another_table it fails. in second case f1.exist() was true but f1.canRead() was false I tried changin read write permission by chmod 777, it didn't worked.

Java code to read file is as follows:

public class config {
  public static final String confFilePath = "/hadoop/yarn/local/usercache/root/test_file
  public static void init(){    
        BufferedReader br;
       try {    
            File f1 = new File(confFilePath);
            if (f1.exists())
            {   if (f1.canRead()){

                br = new BufferedReader( new FileReader( confFilePath ));
                String line;
                line = br.readLine();
                str = line;
                logger.info("inside init");
                }
                else{
                    str = "can't read";
                }
            }

In case of select test('ABCD','ACBD') it reads first line of test_file successfully and in case of Create table as test_tb select test(name,'ABCD') from another_table it return can't read String.

Edit: If this is about adding serde.jar then please redirct me to correct jar to download. HDP sandbox version 2.6.5

0

There are 0 answers