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 @@ -26,6 +26,7 @@
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
import org.apache.druid.error.InvalidInput;
import org.apache.druid.java.util.common.ISE;
import org.apache.druid.segment.DimensionHandlerUtils;
import org.apache.druid.segment.column.ColumnType;
Expand Down Expand Up @@ -62,6 +63,11 @@ public RowBasedIndexBuilder(ColumnType keyType)
{
this.keyType = keyType;

// Cannot build index on complex types, and non-primitive arrays
if (keyType.is(ValueType.COMPLEX) || keyType.isArray() && !keyType.isPrimitiveArray()) {
throw InvalidInput.exception("Cannot join when the join condition has column of type [%s]", keyType);
}

if (keyType.is(ValueType.LONG)) {
// We're specializing the type even though we don't specialize usage in this class, for two reasons:
// (1) It's still useful to reduce overall memory footprint.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.druid.data.input.impl.LongDimensionSchema;
import org.apache.druid.data.input.impl.StringDimensionSchema;
import org.apache.druid.data.input.impl.TimestampSpec;
import org.apache.druid.error.DruidException;
import org.apache.druid.error.DruidExceptionMatcher;
import org.apache.druid.guice.DruidInjectorBuilder;
import org.apache.druid.guice.NestedDataModule;
Expand Down Expand Up @@ -77,6 +78,7 @@
import org.apache.druid.timeline.partition.LinearShardSpec;
import org.hamcrest.CoreMatchers;
import org.junit.internal.matchers.ThrowableMessageMatcher;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
Expand Down Expand Up @@ -5392,6 +5394,19 @@ public void testGroupByRootSingleTypeStringMixed1SparseNotNull()
);
}

@Test
public void testJoinOnNestedColumnThrows()
{
DruidException e = Assertions.assertThrows(DruidException.class, () -> {
testQuery(
"SELECT * FROM druid.nested a INNER JOIN druid.nested b ON a.nester = b.nester",
ImmutableList.of(),
ImmutableList.of()
);
});
Assertions.assertEquals("Cannot join when the join condition has column of type [COMPLEX<json>]", e.getMessage());
}

@Test
public void testScanStringNotNullCast()
{
Expand Down