File tree Expand file tree Collapse file tree 2 files changed +20
-23
lines changed Expand file tree Collapse file tree 2 files changed +20
-23
lines changed Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ def _pl_tree_to_sql(tree: _ExpressionTree) -> str:
179179 assert isinstance (decimal_value , list ), (
180180 f"A { dtype } should be a two or three member list but got { type (decimal_value )} "
181181 )
182- assert 2 > = len (decimal_value ) <= 3 , (
182+ assert 2 < = len (decimal_value ) <= 3 , (
183183 f"A { dtype } should be a two or three member list but got { len (decimal_value )} member list"
184184 )
185185 return str (Decimal (decimal_value [0 ]) / Decimal (10 ** decimal_value [- 1 ]))
Original file line number Diff line number Diff line change @@ -632,27 +632,24 @@ def test_invalid_expr_json(self):
632632 with pytest .raises (AssertionError , match = "The col name of a Column should be a str but got" ):
633633 _pl_tree_to_sql (json .loads (bad_type_expr ))
634634
635- def test_old_dec (self ):
636- bad_key_expr = """
637- {
638- "BinaryExpr": {
639- "left": { "Column": "foo" },
640- "middle": "Gt",
641- "right": { "Literal": { "Int": 5 } }
642- }
643- }
635+ def test_decimal_scale (self ):
636+ scalar_decimal_no_scale = """
637+ { "Scalar": {
638+ "Decimal": [
639+ 1,
640+ 0
641+ ]
642+ } }
644643 """
645- with pytest .raises (KeyError , match = "'op'" ):
646- _pl_tree_to_sql (json .loads (bad_key_expr ))
647-
648- bad_type_expr = """
649- {
650- "BinaryExpr": {
651- "left": { "Column": [ "foo" ] },
652- "op": "Gt",
653- "right": { "Literal": { "Int": 5 } }
654- }
655- }
644+ assert _pl_tree_to_sql (json .loads (scalar_decimal_no_scale )) == "1"
645+
646+ scalar_decimal_scale = """
647+ { "Scalar": {
648+ "Decimal": [
649+ 1,
650+ 38,
651+ 0
652+ ]
653+ } }
656654 """
657- with pytest .raises (AssertionError , match = "The col name of a Column should be a str but got" ):
658- _pl_tree_to_sql (json .loads (bad_type_expr ))
655+ assert _pl_tree_to_sql (json .loads (scalar_decimal_scale )) == "1"
You can’t perform that action at this time.
0 commit comments