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 @@ -1007,7 +1007,7 @@ private List<SegmentIdWithShardSpec> generateSegmentIdsWithShardSpecsForReplace(

// Validate interval against the replaceTimeChunks set of intervals.
if (destination.getReplaceTimeChunks().stream().noneMatch(chunk -> chunk.contains(interval))) {
throw new MSQException(new InsertTimeOutOfBoundsFault(interval));
throw new MSQException(new InsertTimeOutOfBoundsFault(interval, destination.getReplaceTimeChunks()));
}

final List<Pair<Integer, ClusterByPartition>> ranges = bucketEntry.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,31 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import org.joda.time.Interval;

import java.util.List;
import java.util.Objects;

public class InsertTimeOutOfBoundsFault extends BaseMSQFault
{
static final String CODE = "InsertTimeOutOfBounds";

private final Interval interval;
private final List<Interval> intervalBounds;

public InsertTimeOutOfBoundsFault(@JsonProperty("interval") Interval interval)
public InsertTimeOutOfBoundsFault(
@JsonProperty("interval") Interval interval,
@JsonProperty("intervalBounds") List<Interval> intervalBounds
)
{
super(CODE, "Query generated time chunk [%s] out of bounds specified by replaceExistingTimeChunks", interval);
super(
CODE,
"Inserted data contains time chunk[%s] outside of bounds specified by OVERWRITE WHERE[%s]. "
+ "If you want to include this data, expand your OVERWRITE WHERE. "
+ "If you do not want to include this data, use SELECT ... WHERE to filter it from your inserted data.",
interval,
intervalBounds
);
this.interval = interval;
this.intervalBounds = intervalBounds;
}

@JsonProperty
Expand All @@ -42,6 +55,12 @@ public Interval getInterval()
return interval;
}

@JsonProperty
public List<Interval> getIntervalBounds()
{
return intervalBounds;
}

@Override
public boolean equals(Object o)
{
Expand All @@ -55,12 +74,24 @@ public boolean equals(Object o)
return false;
}
InsertTimeOutOfBoundsFault that = (InsertTimeOutOfBoundsFault) o;
return Objects.equals(interval, that.interval);
return Objects.equals(interval, that.interval) && Objects.equals(
intervalBounds,
that.intervalBounds
);
}

@Override
public int hashCode()
{
return Objects.hash(super.hashCode(), interval);
return Objects.hash(super.hashCode(), interval, intervalBounds);
}

@Override
public String toString()
{
return "InsertTimeOutOfBoundsFault{" +
"interval=" + interval +
", intervalBounds=" + intervalBounds +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,12 @@ public void testInsertTimeOutOfBoundsFault()
"replace into foo1 overwrite where __time >= TIMESTAMP '2002-01-02 00:00:00' and __time < TIMESTAMP '2002-01-03 00:00:00' select __time, dim1 , count(*) as cnt from foo where dim1 is not null group by 1, 2 PARTITIONED by day clustered by dim1")
.setExpectedDataSource("foo1")
.setExpectedRowSignature(rowSignature)
.setExpectedMSQFault(new InsertTimeOutOfBoundsFault(Intervals.of("2000-01-02T00:00:00.000Z/2000-01-03T00:00:00.000Z")))
.setExpectedMSQFault(
new InsertTimeOutOfBoundsFault(
Intervals.of("2000-01-02T00:00:00.000Z/2000-01-03T00:00:00.000Z"),
Collections.singletonList(Intervals.of("2002-01-02/2002-01-03"))
)
)
.verifyResults();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;

public class MSQFaultSerdeTest
{
Expand Down Expand Up @@ -63,7 +64,10 @@ public void testFaultSerde() throws IOException
assertFaultSerde(new InsertCannotBeEmptyFault("the datasource"));
assertFaultSerde(InsertLockPreemptedFault.INSTANCE);
assertFaultSerde(InsertTimeNullFault.INSTANCE);
assertFaultSerde(new InsertTimeOutOfBoundsFault(Intervals.ETERNITY));
assertFaultSerde(new InsertTimeOutOfBoundsFault(
Intervals.of("2001/2002"),
Collections.singletonList(Intervals.of("2000/2001"))
));
assertFaultSerde(new InvalidNullByteFault("the source", 1, "the column", "the value", 2));
assertFaultSerde(new NotEnoughMemoryFault(1000, 1000, 900, 1, 2));
assertFaultSerde(QueryNotSupportedFault.INSTANCE);
Expand Down