Column names with '-' create invalid property names in generated code
Column names that contain a '-' create a generated class that can't be compiled. I'm using MySQL which allows such characters.
To fix, I changed the SqlManager class getColumnNames and getColumnTypes methods to replace the '-' with '_' on the colName string.
I'm sure there are other column characters that are illegal java identifiers, so perhaps a general escape mechanism should be applied.
- Ferdy
To fix, I changed the SqlManager class getColumnNames and getColumnTypes methods to replace the '-' with '_' on the colName string.
I'm sure there are other column characters that are illegal java identifiers, so perhaps a general escape mechanism should be applied.
- Ferdy
1
person has this problem
I have this problem, too!
Tell me when someone solves it.
The more people who report this problem, the more it gets noticed.
The more people who report this problem, the more it gets noticed.
-
Inappropriate?Hi Ferdy,
Good catch! :) I don't think that changing SqlManager.getColumnNames() is the best idea though; that might get used to interact with the SQL database itself. The correct fix is probably to put an escaping function in o.a.h.sqoop.orm.ClassWriter. I'll work on getting a more general fix in there with some unit tests.
Thanks!
- Aaron
1 person says
this solves the problem
-
Inappropriate?to expand on this issue, sqoop fails to import a table if a column is named the same as a java keyword. in my case, i have a column called 'class' which sqoop chokes on.
-
Inappropriate?Oops. Good catch.
Loading Profile...


