All Forums Database
22 Aug 2016
Teradata Implicit Casting

Hi,
I was just curious to know what would happen when 2 columns with different data types integer and byteint is joined together?
According to me the byteint should be converted to integer. However I believe I read somewhere that they are both converted to FLOAT.
Please help.  

bhavesh_09 3 posts Joined 06/12
23 Aug 2016

Hi,
What do you mean by "joined together". does it mean concat?
if it is concat then you can check it by using 

select type(cast(123456 as integer)||cast(123 as byteint))

 

23 Aug 2016

No.
Say 2 tables table_a with column a byteint and other table_b with column b integer
When they are joined together :
 
Select * from table_a join table_b on table_a.a=table_b.b
What is the implicit casting going on ?

Fred 1096 posts Joined 08/04
23 Aug 2016

See the "Implicit Type Conversion of Comparison Operands" topic in SQL Reference: Functions, Operators, Expressions, and Predicates manual.
In general, comparing (or joining on) two numeric columns works as you expect. For example, BYTEINT will be implicitly converted to INTEGER for comparison.
 
But if you compare a numeric column with a character column, Teradata attempts to convert both to FLOAT.

23 Aug 2016

Thanks Fred. This document contains everything :)

You must sign in to leave a comment.