Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

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

Highlighted

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;
   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";}}
  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

Don't have an account?
Coming from Hortonworks? Activate your account here