Teradata support

As per overview in #304 to resolve #168 and #7.
If it's only whitespace changes here - better to have them as separate pull request.