mirror of https://github.com/apache/druid.git
MSQ: Improve InsertTimeOutOfBounds error message. (#14511)
Nicer and actionable error message for `InsertTimeOutOfBounds` fault
This commit is contained in:
parent
67fbd8e7fc
commit
048dbcee88
|
@ -1007,7 +1007,7 @@ public class ControllerImpl implements Controller
|
||||||
|
|
||||||
// Validate interval against the replaceTimeChunks set of intervals.
|
// Validate interval against the replaceTimeChunks set of intervals.
|
||||||
if (destination.getReplaceTimeChunks().stream().noneMatch(chunk -> chunk.contains(interval))) {
|
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();
|
final List<Pair<Integer, ClusterByPartition>> ranges = bucketEntry.getValue();
|
||||||
|
|
|
@ -22,6 +22,7 @@ package org.apache.druid.msq.indexing.error;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import org.joda.time.Interval;
|
import org.joda.time.Interval;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class InsertTimeOutOfBoundsFault extends BaseMSQFault
|
public class InsertTimeOutOfBoundsFault extends BaseMSQFault
|
||||||
|
@ -29,11 +30,23 @@ public class InsertTimeOutOfBoundsFault extends BaseMSQFault
|
||||||
static final String CODE = "InsertTimeOutOfBounds";
|
static final String CODE = "InsertTimeOutOfBounds";
|
||||||
|
|
||||||
private final Interval interval;
|
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.interval = interval;
|
||||||
|
this.intervalBounds = intervalBounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
|
@ -42,6 +55,12 @@ public class InsertTimeOutOfBoundsFault extends BaseMSQFault
|
||||||
return interval;
|
return interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
public List<Interval> getIntervalBounds()
|
||||||
|
{
|
||||||
|
return intervalBounds;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o)
|
public boolean equals(Object o)
|
||||||
{
|
{
|
||||||
|
@ -55,12 +74,24 @@ public class InsertTimeOutOfBoundsFault extends BaseMSQFault
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
InsertTimeOutOfBoundsFault that = (InsertTimeOutOfBoundsFault) o;
|
InsertTimeOutOfBoundsFault that = (InsertTimeOutOfBoundsFault) o;
|
||||||
return Objects.equals(interval, that.interval);
|
return Objects.equals(interval, that.interval) && Objects.equals(
|
||||||
|
intervalBounds,
|
||||||
|
that.intervalBounds
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
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 +
|
||||||
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,12 @@ public class MSQFaultsTest extends MSQTestBase
|
||||||
"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")
|
"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")
|
.setExpectedDataSource("foo1")
|
||||||
.setExpectedRowSignature(rowSignature)
|
.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();
|
.verifyResults();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.junit.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
public class MSQFaultSerdeTest
|
public class MSQFaultSerdeTest
|
||||||
{
|
{
|
||||||
|
@ -63,7 +64,10 @@ public class MSQFaultSerdeTest
|
||||||
assertFaultSerde(new InsertCannotBeEmptyFault("the datasource"));
|
assertFaultSerde(new InsertCannotBeEmptyFault("the datasource"));
|
||||||
assertFaultSerde(InsertLockPreemptedFault.INSTANCE);
|
assertFaultSerde(InsertLockPreemptedFault.INSTANCE);
|
||||||
assertFaultSerde(InsertTimeNullFault.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 InvalidNullByteFault("the source", 1, "the column", "the value", 2));
|
||||||
assertFaultSerde(new NotEnoughMemoryFault(1000, 1000, 900, 1, 2));
|
assertFaultSerde(new NotEnoughMemoryFault(1000, 1000, 900, 1, 2));
|
||||||
assertFaultSerde(QueryNotSupportedFault.INSTANCE);
|
assertFaultSerde(QueryNotSupportedFault.INSTANCE);
|
||||||
|
|
Loading…
Reference in New Issue