File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1394,20 +1394,45 @@ def test_sql_data_types():
13941394 tm .assert_frame_equal (pandas_frame , my_frame )
13951395
13961396
1397- def test_math_parentheses ():
1397+ def test_order_of_operations_no_parens ():
13981398 """
13991399 Test math parentheses
14001400 :return:
14011401 """
14021402
1403- my_frame = query ("select 20 * avocado_id from avocado" )
1403+ my_frame = query ("select 20 * avocado_id + 3 / 20 as my_math from avocado" )
14041404
1405- print (my_frame )
1405+ pandas_frame = AVOCADO .copy ()[["avocado_id" ]]
1406+ pandas_frame ["my_math" ] = 20 * pandas_frame ["avocado_id" ] + 3 / 20
1407+
1408+ pandas_frame = pandas_frame .drop (columns = ["avocado_id" ])
1409+
1410+ tm .assert_frame_equal (pandas_frame , my_frame )
1411+
1412+
1413+ # def test_order_of_operations_with_parens():
1414+ # """
1415+ # Test math parentheses
1416+ # :return:
1417+ # """
1418+ #
1419+ # my_frame = query(
1420+ # "select 20 * (avocado_id + 3) / (20 + avocado_id) as my_math from " "avocado"
1421+ # )
1422+ #
1423+ # pandas_frame = AVOCADO.copy()[["avocado_id"]]
1424+ # pandas_frame["my_math"] = (
1425+ # 20 * (pandas_frame["avocado_id"] + 3) / (20 + pandas_frame["avocado_id"])
1426+ # )
1427+ #
1428+ # pandas_frame = pandas_frame.drop(columns=["avocado_id"])
1429+ #
1430+ # tm.assert_frame_equal(pandas_frame, my_frame)
14061431
14071432
14081433if __name__ == "__main__" :
14091434 register_env_tables ()
14101435
1411- test_right_left_math ()
1436+ # test_order_of_operations_with_parens ()
14121437
14131438 remove_env_tables ()
Original file line number Diff line number Diff line change @@ -82,7 +82,8 @@ def test_using_math():
8282 "select temp, 1 + 2 * 3 as my_number from forest_fires" ,
8383 show_execution_plan = True ,
8484 )
85- assert plan == "FOREST_FIRES.loc[:, ['temp']].assign(my_number=7, )"
85+
86+ assert plan == "FOREST_FIRES.loc[:, ['temp']].assign(my_number=1 + 2 * 3)"
8687
8788
8889def test_distinct ():
@@ -1086,6 +1087,6 @@ def test_timestamps():
10861087if __name__ == "__main__" :
10871088 register_env_tables ()
10881089
1089- # test_rank_statement_one_column ()
1090+ test_using_math ()
10901091
10911092 remove_env_tables ()
You can’t perform that action at this time.
0 commit comments