Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement distinct in AggFunction #14623

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
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 @@ -119,6 +119,8 @@ public class IoTDBUserDefinedAggregateFunctionIT {
public static void setUp() throws Exception {
EnvFactory.getEnv().initClusterEnvironment();
insertData();
SQLFunctionUtils.createUDF(
"my_count", "org.apache.iotdb.db.query.udf.example.relational.MyCount");
}

@AfterClass
Expand All @@ -145,8 +147,6 @@ private static void insertData() {

@Test
public void testMyCount() {
SQLFunctionUtils.createUDF(
"my_count", "org.apache.iotdb.db.query.udf.example.relational.MyCount");
String[] expectedHeader = new String[] {"_col0"};
String[] retArray =
new String[] {
Expand Down Expand Up @@ -687,4 +687,53 @@ public void testFirstTwoSum() {
retArray,
DATABASE_NAME);
}

@Test
public void testDistinct() {
String[] expectedHeader =
new String[] {
"_col0", "_col1", "_col2", "_col3", "_col4", "_col5", "_col6", "_col7", "_col8", "_col9",
"_col10", "_col11", "_col12", "_col13"
};
String[] retArray =
new String[] {
"2,2,4,16,5,5,5,5,2,24,32,5,10,1,",
};
// global Aggregation
tableResultSetEqualTest(
"select my_count(distinct province), my_count(distinct city), my_count(distinct region), my_count(distinct device_id), my_count(distinct s1), my_count(distinct s2), my_count(distinct s3), my_count(distinct s4), my_count(distinct s5), my_count(distinct s6), my_count(distinct s7), my_count(distinct s8), my_count(distinct s9), my_count(distinct s10) from table1",
expectedHeader,
retArray,
DATABASE_NAME);

expectedHeader =
new String[] {
"province",
"city",
"region",
"_col3",
"_col4",
"_col5",
"_col6",
"_col7",
"_col8",
"_col9",
"_col10",
"_col11",
"_col12"
};
retArray =
new String[] {
"beijing,beijing,chaoyang,5,5,5,5,2,6,8,5,10,1,",
"beijing,beijing,haidian,5,5,5,5,2,6,8,5,10,1,",
"shanghai,shanghai,huangpu,5,5,5,5,2,6,8,5,10,1,",
"shanghai,shanghai,pudong,5,5,5,5,2,6,8,5,10,1,"
};
// group by Aggregation
tableResultSetEqualTest(
"select province,city,region, my_count(distinct s1), my_count(distinct s2), my_count(distinct s3), my_count(distinct s4), my_count(distinct s5), my_count(distinct s6), my_count(distinct s7), my_count(distinct s8), my_count(distinct s9), my_count(distinct s10) from table1 group by 1,2,3 order by 1,2,3",
expectedHeader,
retArray,
DATABASE_NAME);
}
}
Loading
Loading