code: func unionJoinFieldType(a, b *types.FieldType) *types.FieldType {
  	resultTp := types.NewFieldType(types.MergeFieldType(a.Tp, b.Tp))
  	// This logic will be intelligible when it is associated with the buildProjection4Union logic.
  	if resultTp.Tp == mysql.TypeNewDecimal {
  		// The decimal result type will be unsigned only when all the decimals to be united are unsigned.
  		resultTp.Flag &= b.Flag & mysql.UnsignedFlag
  	} else {
  		// Non-decimal results will be unsigned when the first SQL statement result in the union is unsigned.
  		resultTp.Flag |= a.Flag & mysql.UnsignedFlag
  	}
  	resultTp.Decimal = mathutil.Max(a.Decimal, b.Decimal)
  	// `Flen - Decimal` is the fraction before '.'
  	resultTp.Flen = mathutil.Max(a.Flen-a.Decimal, b.Flen-b.Decimal) + resultTp.Decimal
  	if resultTp.EvalType() != types.ETInt && (a.EvalType() == types.ETInt || b.EvalType() == types.ETInt) && resultTp.Flen < mysql.MaxIntWidth {
  		resultTp.Flen = mysql.MaxIntWidth
  	}
  	resultTp.Charset = a.Charset
  	resultTp.Collate = a.Collate
  	expression.SetBinFlagOrBinStr(b, resultTp)
  	return resultTp
  }
docs: // unionJoinFieldType finds the type which can carry the given types in Union.