<s> import ibis . expr . api as api <EOL> import ibis . expr . types as ir <EOL> import ibis . expr . operations as ops <EOL> from ibis . compat import unittest <EOL> from ibis . expr . tests . mocks import MockConnection <EOL> class TestDecimal ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . con = MockConnection ( ) <EOL> self . lineitem = self . con . table ( '<STR_LIT>' ) <EOL> def test_type_metadata ( self ) : <EOL> col = self . lineitem . l_extendedprice <EOL> assert isinstance ( col , ir . DecimalArray ) <EOL> assert col . _precision == <NUM_LIT:12> <EOL> assert col . _scale == <NUM_LIT:2> <EOL> def test_cast_scalar_to_decimal ( self ) : <EOL> val = api . literal ( '<STR_LIT>' ) <EOL> casted = val . cast ( '<STR_LIT>' ) <EOL> assert isinstance ( casted , ir . DecimalScalar ) <EOL> assert casted . _precision == <NUM_LIT:15> <EOL> assert casted . _scale == <NUM_LIT:5> <EOL> def test_decimal_aggregate_function_behavior ( self ) : <EOL> col = self . lineitem . l_extendedprice <EOL> functions = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> for func_name in functions : <EOL> result = getattr ( col , func_name ) ( ) <EOL> assert isinstance ( result , ir . DecimalScalar ) <EOL> assert result . _precision == col . _precision <EOL> assert result . _scale == <NUM_LIT> <EOL> def test_where ( self ) : <EOL> table = self . lineitem <EOL> q = table . l_quantity <EOL> expr = api . where ( table . l_discount > <NUM_LIT:0> , <EOL> q * table . l_discount , api . null ) <EOL> assert isinstance ( expr , ir . DecimalArray ) <EOL> expr = api . where ( table . l_discount > <NUM_LIT:0> , <EOL> ( q * table . l_discount ) . sum ( ) , api . null ) <EOL> assert isinstance ( expr , ir . DecimalArray ) <EOL> expr = api . where ( table . l_discount . sum ( ) > <NUM_LIT:0> , <EOL> ( q * table . l_discount ) . sum ( ) , api . null ) <EOL> assert isinstance ( expr , ir . DecimalScalar ) <EOL> def test_fillna ( self ) : <EOL> expr = self . lineitem . l_extendedprice . fillna ( <NUM_LIT:0> ) <EOL> assert isinstance ( expr , ir . DecimalArray ) <EOL> expr = self . lineitem . l_extendedprice . fillna ( <EOL> self . lineitem . l_quantity ) <EOL> assert isinstance ( expr , ir . DecimalArray ) <EOL> def test_precision_scale ( self ) : <EOL> col = self . lineitem . l_extendedprice <EOL> p = col . precision ( ) <EOL> s = col . scale ( ) <EOL> assert isinstance ( p , ir . IntegerValue ) <EOL> assert isinstance ( p . op ( ) , ops . DecimalPrecision ) <EOL> assert isinstance ( s , ir . IntegerValue ) <EOL> assert isinstance ( s . op ( ) , ops . DecimalScale ) <EOL> def test_invalid_precision_scale_combo ( self ) : <EOL> pass </s>
