Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.
Closed
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 @@ -143,7 +143,16 @@ public WindowAggExec(TaskAttemptContext context, WindowAggNode plan, PhysicalExe

for (SortSpec sortSpec : functions[i].getSortSpecs()) {
if (!rewrittenSchema.contains(sortSpec.getSortKey())) {
additionalSortKeyColumns.add(sortSpec.getSortKey());
// check if additionalSortKeyColumns already has that sort key
boolean newKey = true;
for (Column c : additionalSortKeyColumns) {
if (c.equals(sortSpec.getSortKey())) {
newKey = false;
}
}
if (newKey) {
additionalSortKeyColumns.add(sortSpec.getSortKey());
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,33 @@ public final void lastValueTime() throws Exception {
executeString("DROP TABLE lastvaluetime PURGE");
}
}

@Test
public final void testMultipleWindow() throws Exception {
KeyValueSet tableOptions = new KeyValueSet();
tableOptions.set(StorageConstants.TEXT_DELIMITER, StorageConstants.DEFAULT_FIELD_DELIMITER);
tableOptions.set(StorageConstants.TEXT_NULL, "\\\\N");

Schema schema = new Schema();
schema.addColumn("id", TajoDataTypes.Type.INT4);
schema.addColumn("time", TajoDataTypes.Type.TIME);
schema.addColumn("name", TajoDataTypes.Type.TEXT);
String[] data = new String[]{ "1|12:11:12|abc", "2|10:11:13|def", "2|05:42:41|ghi" };
TajoTestingCluster.createTable("multiwindow", schema, tableOptions, data, 1);

try {
ResultSet res = executeString(
"select id, last_value(time) over ( partition by id order by time ) as time_last, last_value(name) over ( partition by id order by time ) as name_last from multiwindow");
String ascExpected = "id,time_last,name_last\n" +
"-------------------------------\n" +
"1,12:11:12,abc\n" +
"2,10:11:13,def\n" +
"2,10:11:13,def\n";

assertEquals(ascExpected, resultSetToString(res));
res.close();
} finally {
executeString("DROP TABLE multiwindow PURGE");
}
}
}