sqoop-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From redshift-etl-user <redshift....@gmail.com>
Subject Null values and escaping
Date Fri, 03 Jan 2014 12:34:46 GMT
I'm importing from a DB into a text file, and I need to distinguish between
null and non-null strings. Is there a combination of parameters (i.e.
escaped-by, enclosed-by, and null-string) that yields unambiguous output
strings? With the default options "null-string" is "null", and so there's
no way of distinguishing between a null string and the string "null" in the
output file.

One solution to this would be to avoid escaping the specified null string.
That way we could specify "escaped-by" as "\" and "null-string" as "\N" and
get "\N" in the output as opposed to "\\N" for null strings. That way it's
guaranteed to be different from any non-null string.

In the generated code's toString() method this would mean changing from

__sb.append(FieldFormatter.escapeAndEnclose(STRING==null?"\\N":STRING,
delimiters));

to

__sb.append(STRING==null?"\\N":FieldFormatter.escapeAndEnclose(STRING,
delimiters));

Thoughts? Any ideas for a workaround?

Thanks!

Mime
View raw message