Skip to content

Commit

Permalink
[FLINK-20828][python] Fix some aggregate and flat_aggregate tests fai…
Browse files Browse the repository at this point in the history
…led in py35 (apache#14540)
  • Loading branch information
HuangXingBo authored Jan 2, 2021
1 parent 8545621 commit bab7632
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 6 additions & 5 deletions flink-python/pyflink/table/tests/test_row_based_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ def test_aggregate(self):
.aggregate(agg.alias("c", "d")) \
.select("a, c, d") \
.to_pandas()
assert_frame_equal(result, pd.DataFrame([[1, 3, 15], [2, 2, 4]], columns=['a', 'c', 'd']))
assert_frame_equal(result.sort_values('a').reset_index(drop=True),
pd.DataFrame([[1, 3, 15], [2, 2, 4]], columns=['a', 'c', 'd']))

def test_flat_aggregate(self):
import pandas as pd
Expand Down Expand Up @@ -279,11 +280,11 @@ def test_flat_aggregate_list_view(self):
.flat_aggregate(my_concat(t.b, ',').alias("b")) \
.select(t.b, t.c) \
.alias("a, c")
assert_frame_equal(result.to_pandas(),
pd.DataFrame([["Hi,Hi2,Hi,Hi3,Hi3", "hi"],
["Hi,Hi2,Hi,Hi3,Hi3", "hi"],
assert_frame_equal(result.to_pandas().sort_values('c').reset_index(drop=True),
pd.DataFrame([["Hi,Hi,Hi2,Hi2,Hi3", "Hello"],
["Hi,Hi,Hi2,Hi2,Hi3", "Hello"],
["Hi,Hi,Hi2,Hi2,Hi3", "Hello"]],
["Hi,Hi2,Hi,Hi3,Hi3", "hi"],
["Hi,Hi2,Hi,Hi3,Hi3", "hi"]],
columns=['a', 'c']))


Expand Down
12 changes: 6 additions & 6 deletions flink-python/pyflink/table/tests/test_udaf.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,9 @@ def test_list_view(self):
(3, 'Hi3', 'hi'),
(2, 'Hi3', 'Hello')], ['a', 'b', 'c'])
result = t.group_by(t.c).select(my_concat(t.b, ',').alias("a"), t.c)
assert_frame_equal(result.to_pandas(),
pd.DataFrame([["Hi,Hi2,Hi,Hi3,Hi3", "hi"],
["Hi,Hi,Hi2,Hi2,Hi3", "Hello"]], columns=['a', 'c']))
assert_frame_equal(result.to_pandas().sort_values('c').reset_index(drop=True),
pd.DataFrame([["Hi,Hi,Hi2,Hi2,Hi3", "Hello"],
["Hi,Hi2,Hi,Hi3,Hi3", "hi"]], columns=['a', 'c']))

def test_map_view(self):
my_count = udaf(CountDistinctAggregateFunction())
Expand Down Expand Up @@ -465,10 +465,10 @@ def test_map_view_iterate(self):
col("a").get(3).alias("d"),
t.c.alias("e"))
assert_frame_equal(
result.to_pandas(),
result.to_pandas().sort_values('c').reset_index(drop=True),
pd.DataFrame([
["hello,hello2", "1,3", 'hello:3,hello2:1', 2, "hello"],
["Hi,Hi2,Hi3", "1,2,3", "Hi:3,Hi2:2,Hi3:1", 3, "hi"]],
["Hi,Hi2,Hi3", "1,2,3", "Hi:3,Hi2:2,Hi3:1", 3, "hi"],
["hello,hello2", "1,3", 'hello:3,hello2:1', 2, "hello"]],
columns=['a', 'b', 'c', 'd', 'e']))

def test_distinct_and_filter(self):
Expand Down

0 comments on commit bab7632

Please sign in to comment.