Uploaded image for project: 'Sqoop'
  1. Sqoop
  2. SQOOP-3159

Sqoop (export + --table) with Oracle table_name having '$' fails with error (ORA-00942 or java.lang.NoClassDefFoundError)

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4.7
    • Component/s: None
    • Labels:
      None

      Description

      Sqoop (export + --table) with Oracle table_name having '$' fails with error (ORA-00942 or java.lang.NoClassDefFoundError), see test case below.

      Test Case

      #################
      # STEP 01 - Create Data
      #################
      
      export MYCONN=jdbc:oracle:thin:@oracle1.cloudera.com:1521/db11g;
      export MYUSER=sqoop
      export MYPSWD=cloudera
      
      sqoop eval --connect $MYCONN --username $MYUSER --password $MYPSWD --query "drop table t1"
      sqoop eval --connect $MYCONN --username $MYUSER --password $MYPSWD --query "create table t1 (c1 int, c2 date, c3 varchar(10))"
      sqoop eval --connect $MYCONN --username $MYUSER --password $MYPSWD --query "insert into t1 values (1, current_date, 'some data')"
      sqoop eval --connect $MYCONN --username $MYUSER --password $MYPSWD --query "select * from t1"
      
      Output:
      -----------------------------------------------
      | C1                   | C2      | C3         | 
      -----------------------------------------------
      | 1                    | 2017-03-21 13:30:02.0 | some data  | 
      -----------------------------------------------
      
      sqoop eval --connect $MYCONN --username $MYUSER --password $MYPSWD --query "drop table t\$1"
      sqoop eval --connect $MYCONN --username $MYUSER --password $MYPSWD --query "create table t\$1 (c1 int, c2 date, c3 varchar(10))"
      sqoop eval --connect $MYCONN --username $MYUSER --password $MYPSWD --query "insert into t\$1 values (1, current_date, 'some data')"
      sqoop eval --connect $MYCONN --username $MYUSER --password $MYPSWD --query "select * from t\$1"
      
      Output:
      -----------------------------------------------
      | C1                   | C2      | C3         | 
      -----------------------------------------------
      | 1                    | 2017-03-21 13:31:18.0 | some data  | 
      -----------------------------------------------
      
      #################
      # STEP 02 - Import and Export without '$' (baseline)
      #################
      
      sqoop import --connect $MYCONN --username $MYUSER --password $MYPSWD --table "T1" --target-dir /user/root/t1 --delete-target-dir --num-mappers 1
      hdfs dfs -cat /user/root/t1/part*
      
      Output:
      17/03/21 06:39:31 INFO mapreduce.ImportJobBase: Transferred 34 bytes in 21.6129 seconds (1.5731 bytes/sec)
      17/03/21 06:39:31 INFO mapreduce.ImportJobBase: Retrieved 1 records.
      ~~~~~
      1,2017-03-21 13:30:02.0,some data
      
      sqoop export --connect $MYCONN --username $MYUSER --password $MYPSWD --table T1 --export-dir /user/root/t1 --num-mappers 1
      sqoop eval --connect $MYCONN --username $MYUSER --password $MYPSWD --query "select * from t1"
      
      Output:
      17/03/21 06:46:07 INFO mapreduce.ExportJobBase: Transferred 163 bytes in 21.4938 seconds (7.5836 bytes/sec)
      17/03/21 06:46:07 INFO mapreduce.ExportJobBase: Exported 1 records.
      ~~~~~
      -----------------------------------------------
      | C1                   | C2      | C3         | 
      -----------------------------------------------
      | 1                    | 2017-03-21 13:30:02.0 | some data  | 
      | 1                    | 2017-03-21 13:30:02.0 | some data  | 
      -----------------------------------------------
      
      #################
      # STEP 03 - Export with '$' (--table T$1)
      #################
      
      sqoop export --connect $MYCONN --username $MYUSER --password $MYPSWD --table T$1 --export-dir /user/root/t1 --num-mappers 1
      
      Output:
      17/03/21 06:49:28 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM "T" t WHERE 1=0
      17/03/21 06:49:28 ERROR manager.SqlManager: Error executing statement: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
      
      #################
      # STEP 04 - Export with '$' (--table T\$1)
      #################
      
      sqoop export --connect $MYCONN --username $MYUSER --password $MYPSWD --table T\$1 --export-dir /user/root/t1 --num-mappers 1
      
      Output:
      17/03/22 07:27:26 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM "T$1" t WHERE 1=0
      17/03/22 07:27:26 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /opt/cloudera/parcels/CDH/lib/hadoop-mapreduce
      17/03/22 07:27:27 INFO mapreduce.ExportJobBase: Beginning export of T$1
      ~~~~
      2017-03-22 07:27:54,215 WARN [main] org.apache.hadoop.mapred.YarnChild: Exception running child : java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
      	at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:131)
      	at org.apache.sqoop.mapreduce.TextExportMapper.setup(TextExportMapper.java:72)
      	at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:142)
      	at org.apache.sqoop.mapreduce.AutoProgressMapper.run(AutoProgressMapper.java:64)
      	at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:787)
      	at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
      	at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at javax.security.auth.Subject.doAs(Subject.java:415)
      	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1714)
      	at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)
      Caused by: java.lang.reflect.InvocationTargetException
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
      	at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:129)
      	... 10 more
      Caused by: java.lang.NoClassDefFoundError: T$1$1
      	at T$1.init0(T$1.java:43)
      	at T$1.<init>(T$1.java:63)
      	... 15 more
      
      #################
      # STEP 05 - Export with '$' (--table "T$1")
      #################
      
      sqoop export --connect $MYCONN --username $MYUSER --password $MYPSWD --table "T$1" --export-dir /user/root/t1 --num-mappers 1
      
      Output:
      17/03/21 06:50:17 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM "T" t WHERE 1=0
      17/03/21 06:50:17 ERROR manager.SqlManager: Error executing statement: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
      
      #################
      # STEP 06 - Export with '$' (--table "T\$1")
      #################
      
      sqoop export --connect $MYCONN --username $MYUSER --password $MYPSWD --table "T\$1" --export-dir /user/root/t1 --num-mappers 1
      
      Output:
      17/03/21 06:50:59 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM "T$1" t WHERE 1=0
      17/03/21 06:50:59 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /opt/cloudera/parcels/CDH/lib/hadoop-mapreduce
      17/03/21 06:51:00 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-root/compile/f0d0532c88ac71406aa4114886b2f1b4/T$1.jar
      17/03/21 06:51:00 INFO mapreduce.ExportJobBase: Beginning export of T$1
      ~~~~~
      2017-03-21 06:51:20,213 WARN [main] org.apache.hadoop.mapred.YarnChild: Exception running child : java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
      	at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:131)
      	at org.apache.sqoop.mapreduce.TextExportMapper.setup(TextExportMapper.java:72)
      	at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:142)
      	at org.apache.sqoop.mapreduce.AutoProgressMapper.run(AutoProgressMapper.java:64)
      	at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:787)
      	at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
      	at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at javax.security.auth.Subject.doAs(Subject.java:415)
      	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1714)
      	at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)
      Caused by: java.lang.reflect.InvocationTargetException
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
      	at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:129)
      	... 10 more
      Caused by: java.lang.NoClassDefFoundError: T$1$1
      	at T$1.init0(T$1.java:43)
      	at T$1.<init>(T$1.java:63)
      	... 15 more
      Caused by: java.lang.ClassNotFoundException: T$1$1
      	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
      	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
      	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
      	... 17 more
      

        Attachments

        1. SQOOP-3159.patch
          12 kB
          Szabolcs Vasas

          Issue Links

            Activity

              People

              • Assignee:
                vasas Szabolcs Vasas
                Reporter:
                markuskemper@me.com Markus Kemper
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: