def test_cast_from_decimal_to_decimal(self): self.assertEqual( cast_to_decimal(cast_to_decimal(1.526, FloatType(), DecimalType(scale=2), options=BASE_OPTIONS), DecimalType(scale=2), DecimalType(scale=3), options=BASE_OPTIONS), 1.53)
def test_cast_map_to_map(self): self.assertEqual( cast_to_map({ 1: "1", 2: "2" }, MapType(ByteType(), StringType()), MapType(StringType(), FloatType()), options=BASE_OPTIONS), { '1': 1.0, '2': 2.0 })
def test_cast_float_to_decimal_with_scale_and_other_rounding(self): self.assertEqual( cast_to_decimal(10.987654321, FloatType(), DecimalType(precision=10, scale=8), options=BASE_OPTIONS), 10.98765432)
def test_cast_float_to_decimal_with_scale(self): self.assertEqual( cast_to_decimal(10.123456789, FloatType(), DecimalType(precision=10, scale=8), options=BASE_OPTIONS), 10.12345679)
def test_cast_float_to_short_with_loop(self): self.assertEqual( cast_to_short(32768, FloatType(), options=BASE_OPTIONS), -32768)
def test_cast_float_to_short(self): self.assertEqual( cast_to_short(32767, FloatType(), options=BASE_OPTIONS), 32767)
def test_cast_float_to_byte_with_loop(self): self.assertEqual( cast_to_byte(-730.8, FloatType(), options=BASE_OPTIONS), 38)
def test_cast_float_to_byte(self): self.assertEqual( cast_to_byte(-128.8, FloatType(), options=BASE_OPTIONS), -128)