Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class MedianConvert implements ExpressionPatternRuleFactory {
public List<ExpressionPatternMatcher<? extends Expression>> buildRules() {
return ImmutableList.of(
matchesType(Median.class).then(median ->
new Percentile(median.child(0), DoubleLiteral.of(0.5))
new Percentile(median.isDistinct(), median.child(0), DoubleLiteral.of(0.5))
).toRule(ExpressionRuleType.MEDIAN_CONVERT)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
-- !select_6 --
2001 125.5

-- !median_distinct --
5.5 1

Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ suite("test_convert_median_to_percentile") {
qt_select_5 "${sql5}"
qt_select_6 "${sql6}"

sql "DROP TABLE IF EXISTS median_distinct"
sql """
CREATE TABLE median_distinct (
id INT,
value INT
)
DISTRIBUTED BY HASH(id) BUCKETS 1
PROPERTIES ("replication_num" = "1")
"""
sql "INSERT INTO median_distinct VALUES (1, 1), (2, 1), (3, 10)"
order_qt_median_distinct "SELECT median(DISTINCT value), median(value) FROM median_distinct"
sql "DROP TABLE IF EXISTS median_distinct"

sql "DROP TABLE if exists sales"
sql "DROP DATABASE if exists test_convert_median_to_percentile"
}
Loading