Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Function of REPLACE throws IndexOutOfBoundsException, if text's length is more than previously applied.
TEST-CASE:
// TestStringFunctions#testReplaceOutBuffer @Test public void testReplaceOutBuffer() throws Exception { String originValue = RandomStringUtils.randomAlphabetic(8192).toLowerCase() + "12345"; String expectValue = originValue.replace("12345", "67890"); String sql = "select replace(c1, '12345', '67890') as col from (values('" + originValue + "')) as t(c1)"; testBuilder() .sqlQuery(sql) .ordered() .baselineColumns("col") .baselineValues(expectValue) .go(); }
Error-Stack:
java.lang.Exception: org.apache.drill.common.exceptions.UserRemoteException: SYSTEM ERROR: IndexOutOfBoundsException: DrillBuf[143], udle: [107 0..8192], index: 8192, length: 1 (expected: range(0, 8192)) ledger[114] allocator: frag:0:0), isOwning: true, size: 8192, references: 1, life: 61488788902200..0, allocatorManager: [106, life: 61488788791129..0] holds 1 buffers. DrillBuf[143], udle: [107 0..8192] event log for: DrillBuf[143] 61488788929532 create() at org.apache.drill.common.StackTrace.<init>(StackTrace.java:33) at org.apache.drill.common.HistoricalLog$Event.<init>(HistoricalLog.java:39) at org.apache.drill.common.HistoricalLog.recordEvent(HistoricalLog.java:95) at io.netty.buffer.DrillBuf.<init>(DrillBuf.java:89) at org.apache.drill.exec.memory.AllocationManager$BufferLedger.newDrillBuf(AllocationManager.java:384) at org.apache.drill.exec.memory.BaseAllocator.bufferWithoutReservation(BaseAllocator.java:261) at org.apache.drill.exec.memory.BaseAllocator.buffer(BaseAllocator.java:242) at org.apache.drill.exec.ops.BufferManagerImpl.getManagedBuffer(BufferManagerImpl.java:63) at org.apache.drill.exec.ops.BufferManagerImpl.replace(BufferManagerImpl.java:53) at io.netty.buffer.DrillBuf.reallocIfNeeded(DrillBuf.java:101) at org.apache.drill.exec.test.generated.ProjectorGen0.doSetup(ProjectorGen0.java:139) at org.apache.drill.exec.physical.impl.project.ProjectorTemplate.setup(ProjectorTemplate.java:107) at org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.setupNewSchemaFromInput(ProjectRecordBatch.java:289) at org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.setupNewSchema(ProjectRecordBatch.java:265) at org.apache.drill.exec.record.AbstractUnaryRecordBatch.innerNext(AbstractUnaryRecordBatch.java:92) at org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.innerNext(ProjectRecordBatch.java:85) at org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:170) at org.apache.drill.exec.physical.impl.validate.IteratorValidatorBatchIterator.next(IteratorValidatorBatchIterator.java:237) at org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:103) at org.apache.drill.exec.physical.impl.ScreenCreator$ScreenRoot.innerNext(ScreenCreator.java:81) at org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:93)