Skip to content

Commit

Permalink
TEIID-5471 correcting the behavior of string_agg over no values
Browse files Browse the repository at this point in the history
# Conflicts:
#	engine/src/test/java/org/teiid/query/processor/TestWindowFunctions.java
  • Loading branch information
shawkins committed Sep 11, 2018
1 parent 2629baf commit 476be5b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Expand Up @@ -121,7 +121,7 @@ private void writeValue(Object val) throws TeiidProcessingException {
*/
public Object getResult(CommandContext commandContext) throws TeiidProcessingException{
if (this.result == null) {
this.result = buildResult(commandContext);
return null;
}

try {
Expand Down
Expand Up @@ -966,6 +966,22 @@ private FunctionMethod addAgg(Schema s, String name, Class<?> clazz, String retu
helpProcess(plan, dataManager, expected);
}

@Test public void testStringAggNoRows() throws Exception {
// Create query
String sql = "SELECT string_agg(e1, ',') from pm1.g1 where e2 > 10"; //$NON-NLS-1$

// Create expected results
List[] expected = new List[] {
Collections.singletonList(null),
};

FakeDataManager dataManager = new FakeDataManager();
sampleData1(dataManager);

ProcessorPlan plan = helpGetPlan(sql, RealMetadataFactory.example1Cached(), TestAggregatePushdown.getAggregatesFinder());
helpProcess(plan, dataManager, expected);
}

@Test public void testStringAggBinary() throws Exception {
// Create query
String sql = "SELECT cast(string_agg(to_bytes(e1, 'UTF-8'), X'AB') as varbinary) from pm1.g1 group by e3"; //$NON-NLS-1$
Expand Down

0 comments on commit 476be5b

Please sign in to comment.