Support Questions
Find answers, ask questions, and share your expertise

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

New Contributor
  1. 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 file.exist() was true but file.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 {
  publicstaticfinalString confFilePath ="/hadoop/yarn/local/usercache/root/test_file
  public static void init(){
  BufferedReader br;
   File f1 =new File(confFilePath);
   {  if(f1.canRead())
           br =new BufferedReader(new FileReader( confFilePath ));
            String line;
                line = br.readLine();
                str = line;
      "inside init");}
                    str ="can't read";}}
  1. In case of select test('ABCD','ACBD') it reads first line of test_file successfully and in case of
    1. Create table as test_tb select test(name,'ABCD') from another_table it return can't read String.
  2. Edit: If this is about adding serde.jar then please redirct me to correct jar to download. HDP sandbox version 2.6.5