Skip to content
Merged
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 @@ -25,6 +25,7 @@
import it.unimi.dsi.fastutil.ints.IntList;
import org.apache.druid.common.semantic.SemanticCreator;
import org.apache.druid.common.semantic.SemanticUtils;
import org.apache.druid.error.InvalidInput;
import org.apache.druid.java.util.common.ISE;
import org.apache.druid.java.util.common.guava.Sequences;
import org.apache.druid.query.operator.ColumnWithDirection;
Expand Down Expand Up @@ -153,11 +154,28 @@ public Column findColumn(String name)
return new LimitedColumn(retVal, startOffset, endOffset);
}

final Function<RowType, Object> adapterForValue = rowAdapter.columnFunction(name);
final Optional<ColumnType> maybeColumnType = rowSignature.getColumnType(name);
final ColumnType columnType = maybeColumnType.orElse(ColumnType.UNKNOWN_COMPLEX);
final Comparator<Object> comparator = Comparator.nullsFirst(columnType.getStrategy());

final Function<RowType, Object> adapterForValue;
if (columnType.equals(ColumnType.STRING)) {
Comment thread
sreemanamala marked this conversation as resolved.
// special handling to reject MVDs
adapterForValue = f -> {
Comment thread
sreemanamala marked this conversation as resolved.
Object value = rowAdapter.columnFunction(name).apply(f);
if (value instanceof List) {
throw InvalidInput.exception(
"Encountered a multi value column [%s]. Window processing does not support MVDs. "
Comment thread
sreemanamala marked this conversation as resolved.
+ "Consider using UNNEST or MV_TO_ARRAY.",
name
);
}
return value;
};
} else {
adapterForValue = rowAdapter.columnFunction(name);
}

return new Column()
{
@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.apache.druid.error.DruidException;
import org.apache.druid.jackson.DefaultObjectMapper;
import org.apache.druid.java.util.common.ISE;
import org.apache.druid.java.util.common.RE;
Expand Down Expand Up @@ -249,6 +250,28 @@ public void testWithArrayConcat()
.run();
}

@Test
public void testFailure_partitionByMVD()
{
final DruidException e = Assert.assertThrows(
DruidException.class,
() -> testBuilder()
.sql("select cityName, countryName, array_to_mv(array[1,length(cityName)]),\n"
+ "row_number() over (partition by array_to_mv(array[1,length(cityName)]) order by countryName, cityName)\n"
+ "from wikipedia\n"
+ "where countryName in ('Austria', 'Republic of Korea') and cityName is not null\n"
+ "order by 1, 2, 3")
.queryContext(DEFAULT_QUERY_CONTEXT)
.run()
);

assertEquals(
Comment thread
sreemanamala marked this conversation as resolved.
"Encountered a multi value column [v0]. Window processing does not support MVDs. "
+ "Consider using UNNEST or MV_TO_ARRAY.",
e.getMessage()
);
}

private WindowOperatorQuery getWindowOperatorQuery(List<Query<?>> queries)
{
assertEquals(1, queries.size());
Expand Down