I have a string \'20141014123456789\' which represents a timestamp with milliseconds that I need to convert to a timestamp in Hive (0.13.0) without losing the milliseconds.
I found a way to avoid the messy concatenation of substrings using the following code:
select cast(regexp_replace('20141014123456789', '(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{3})', '$1-$2-$3 $4:$5:$6.$7') as timestamp)