diff --git a/splice_machine/src/main/java/com/splicemachine/derby/impl/sql/execute/operations/DerbyScanInformation.java b/splice_machine/src/main/java/com/splicemachine/derby/impl/sql/execute/operations/DerbyScanInformation.java index cece6386f1a..341a02dbd17 100644 --- a/splice_machine/src/main/java/com/splicemachine/derby/impl/sql/execute/operations/DerbyScanInformation.java +++ b/splice_machine/src/main/java/com/splicemachine/derby/impl/sql/execute/operations/DerbyScanInformation.java @@ -462,8 +462,7 @@ protected Qualifier[][] populateQualifiers() throws StandardException { Qualifier[][] scanQualifiers = null; if (scanQualifiersFieldName != null && !skipScanQualifiers) { try { - if (qualifiersField == null) - qualifiersField = activation.getClass().getField(scanQualifiersFieldName); + qualifiersField = activation.getClass().getField(scanQualifiersFieldName); scanQualifiers = (Qualifier[][]) qualifiersField.get(activation); } catch (Exception e) { throw StandardException.unexpectedUserException(e); diff --git a/splice_machine/src/main/java/com/splicemachine/derby/impl/sql/execute/operations/IndexPrefixIteratorOperation.java b/splice_machine/src/main/java/com/splicemachine/derby/impl/sql/execute/operations/IndexPrefixIteratorOperation.java index 6bd7d298d6f..5a360227a47 100644 --- a/splice_machine/src/main/java/com/splicemachine/derby/impl/sql/execute/operations/IndexPrefixIteratorOperation.java +++ b/splice_machine/src/main/java/com/splicemachine/derby/impl/sql/execute/operations/IndexPrefixIteratorOperation.java @@ -216,35 +216,27 @@ public DataSet getDataSet(DataSetProcessor dsp) throws StandardExceptio operationContext = dsp.createOperationContext(this); if (keys == null) { - DataSet ds = getDriverDataSet(createTableScannerBuilder()); - TableScannerIterator tableScannerIterator = (TableScannerIterator) ds.toLocalIterator(); - registerCloseable(tableScannerIterator); // Most of the probing logic is in IndexPrefixIteratorFunction, as created below. - if (isMemPlatform) + if (isMemPlatform) { + DataSet ds = getDriverDataSet(createTableScannerBuilder()); + TableScannerIterator tableScannerIterator = (TableScannerIterator) ds.toLocalIterator(); + registerCloseable(tableScannerIterator); ds = ds.mapPartitions(new IndexPrefixIteratorFunction(operationContext, firstIndexColumnNumber), true); + keys = ds.collect(); + closeFirstTableScanner(tableScannerIterator); + } - // Only grab the first row for non-mem platforms. + // Only use a null DVD from the template row for non-mem platforms. // Use the new custom HBase filter in this case, which needs // the DataValueDescriptor of the first index column to // be passed to the constructor. - if (!isMemPlatform) { - ExecRow firstRow = null; - if (tableScannerIterator.hasNext()) - firstRow = tableScannerIterator.next(); - closeFirstTableScanner(tableScannerIterator); - if (firstRow == null) - return dsp.getEmpty(); - + else { int firstMappedIndexColumnNumber = baseColumnMap[firstIndexColumnNumber-1]+1; ExecRow keyRow = new ValueRow(1); - keyRow.setColumn(1, firstRow.getColumn(firstMappedIndexColumnNumber)); + keyRow.setColumn(1, currentTemplate.getColumn(firstMappedIndexColumnNumber)); keys = new ArrayList<>(); keys.add(keyRow); } - else - keys = ds.collect(); - - closeFirstTableScanner(tableScannerIterator); // IndexPrefixIteratorFunction has set scanKeyPrefix. // Future operations won't want this set, so reset it back to null. @@ -326,7 +318,6 @@ public ScanSetBuilder createTableScannerBuilder() throws StandardExcept localProcessor(getOperation().getActivation(), this); scanInformation.skipQualifiers(true); DataScan dataScan = getNonSIScan(); - scanInformation.skipQualifiers(false); // No need for a large cache since we're // going after a single row on each read. @@ -371,6 +362,7 @@ public DataSet getDriverDataSet(ScanSetBuilder scanSetBuilder) throws StandardException { DataSet dataSet = scanSetBuilder.buildDataSet(this); + scanInformation.skipQualifiers(false); return dataSet; }