Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSQ ingestion: Improve error message on encountering non-long timestamp column #17411

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add tests
  • Loading branch information
Akshat-Jain committed Oct 25, 2024
commit b9443dc4db6b611c1589c51d122eb9cd5a698526
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
import org.apache.druid.indexer.TaskStatusPlus;
import org.apache.druid.java.util.common.DateTimes;
import org.apache.druid.java.util.common.ISE;
import org.apache.druid.java.util.common.StringUtils;
import org.apache.druid.msq.indexing.MSQWorkerTask;
import org.apache.druid.msq.indexing.MSQWorkerTaskLauncher;
import org.apache.druid.msq.indexing.error.InsertTimeNullFault;
import org.apache.druid.msq.indexing.error.MSQErrorReport;
import org.apache.druid.msq.indexing.error.MSQException;
import org.apache.druid.msq.indexing.error.MSQFaultUtils;
Expand All @@ -46,6 +48,7 @@
import org.apache.druid.msq.indexing.error.TooManyWorkersFault;
import org.apache.druid.msq.indexing.error.UnknownFault;
import org.apache.druid.msq.indexing.error.WorkerRpcFailedFault;
import org.apache.druid.segment.column.ColumnHolder;
import org.apache.druid.utils.CollectionUtils;
import org.junit.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -244,6 +247,41 @@ public void test_queryWithoutEnoughSlots_shouldThrowException()
}
}

@Test
public void test_getPrimaryTimestampFromObjectForInsert_longValue()
{
Assert.assertEquals(100, MSQTasks.primaryTimestampFromObjectForInsert(100L));
}

@Test
public void test_getPrimaryTimestampFromObjectForInsert_nullValueShouldThrowError()
{
final MSQException e = Assert.assertThrows(
MSQException.class,
() -> MSQTasks.primaryTimestampFromObjectForInsert(null)
);
Assert.assertEquals(InsertTimeNullFault.INSTANCE, e.getFault());
}

@Test
public void test_getPrimaryTimestampFromObjectForInsert_DoubleValueShouldThrowError()
{
final Object timestamp = 1.693837200123456E15;
final MSQException e = Assert.assertThrows(
MSQException.class,
() -> MSQTasks.primaryTimestampFromObjectForInsert(timestamp)
);
Assert.assertEquals(
UnknownFault.forMessage(
StringUtils.format(
"Incorrect type for column [%s]. Expected LONG but got type [%s]. Please ensure that the value is cast to LONG.",
ColumnHolder.TIME_COLUMN_NAME,
timestamp.getClass().getSimpleName()
)
), e.getFault()
Akshat-Jain marked this conversation as resolved.
Show resolved Hide resolved
);
}

static class TasksTestOverlordClient extends NoopOverlordClient
{
// Num of slots available for tasks
Expand Down
Loading