Teradata support

As per overview in #304 to resolve #168 and #7.
Similar for this - better to split out changes with whitespace reformatting only as separate PR.