Code review comment: If all the user-provided tablet_ids are invalid, will here throw an `Unknown Error` to the MySQL client?

Code under review:
public PlanFragment visitPhysicalOlapScan(OptExpression optExpr, ExecPlan context) {
            PhysicalOlapScanOperator node = (PhysicalOlapScanOperator) optExpr.getOp();

            OlapTable referenceTable = (OlapTable) node.getTable();
            context.getDescTbl().addReferencedTable(referenceTable);
            TupleDescriptor tupleDescriptor = context.getDescTbl().createTupleDescriptor();
            tupleDescriptor.setTable(referenceTable);

            OlapScanNode scanNode = new OlapScanNode(context.getNextNodeId(), tupleDescriptor, "OlapScanNode");
            scanNode.setLimit(node.getLimit());
            scanNode.computeStatistics(optExpr.getStatistics());

            
            try {
                scanNode.updateScanInfo(node.getSelectedPartitionId(),
                        node.getSelectedTabletId(),
                        node.getSelectedIndexId());
                long selectedIndexId = node.getSelectedIndexId();
                long totalTabletsNum = 0;
                
                
                long localBeId = -1;
                if (Config.enable_local_replica_selection) {
                    localBeId = GlobalStateMgr.getCurrentSystemInfo()
                            .getBackendIdByHost(FrontendOptions.getLocalHostAddress());
                }

                List<Long> selectedNonEmptyPartitionIds = node.getSelectedPartitionId().stream().filter(p -> {
                    List<Long> selectTabletIds = scanNode.getPartitionToScanTabletMap().get(p);
                    return selectTabletIds != null && !selectTabletIds.isEmpty();
                }).collect(Collectors.toList());
                scanNode.setSelectedPartitionIds(selectedNonEmptyPartitionIds);
                for (Long partitionId : scanNode.getSelectedPartitionIds()) {
                    List<Long> selectTabletIds = scanNode.getPartitionToScanTabletMap().get(partitionId);
                    Preconditions.checkState(selectTabletIds != null && !selectTabletIds.isEmpty());
                    final Partition partition = referenceTable.getPartition(partitionId);
                    final MaterializedIndex selectedTable = partition.getIndex(selectedIndexId);
                    List<Long> allTabletIds = selectedTable.getTabletIdsInOrder();
                    Map<Long, Integer> tabletId2BucketSeq = Maps.newHashMap();
                    for (int i = 0; i < allTabletIds.size(); i++) {
                        tabletId2BucketSeq.put(allTabletIds.get(i), i);
                    }
                    totalTabletsNum += selectedTable.getTablets().size();
                    scanNode.setTabletId2BucketSeq(tabletId2BucketSeq);
                    List<Tablet> tablets =
                            selectTabletIds.stream().map(selectedTable::getTablet).collect(Collectors.toList());
                    scanNode.addScanRangeLocations(partition, selectedTable, tablets, localBeId);
                }
                scanNode.setTotalTabletsNum(totalTabletsNum);
            } catch (UserException e) {
                throw new StarRocksPlannerException(
                        "Build Exec OlapScanNode fail, scan info is invalid," + e.getMessage(),
                        INTERNAL_ERROR);
            }

            
            for (Map.Entry<ColumnRefOperator, Column> entry : node.getColRefToColumnMetaMap().entrySet()) {
                SlotDescriptor slotDescriptor =
                        context.getDescTbl().addSlotDescriptor(tupleDescriptor, new SlotId(entry.getKey().getId()));
                slotDescriptor.setColumn(entry.getValue());
                slotDescriptor.setIsNullable(entry.getValue().isAllowNull());
                slotDescriptor.setIsMaterialized(true);
                context.getColRefToExpr().put(entry.getKey(), new SlotRef(entry.getKey().toString(), slotDescriptor));
            }

            for (ColumnRefOperator entry : node.getGlobalDictStringColumns()) {
                SlotDescriptor slotDescriptor =
                        context.getDescTbl().addSlotDescriptor(tupleDescriptor, new SlotId(entry.getId()));
                slotDescriptor.setIsNullable(entry.isNullable());
                slotDescriptor.setType(entry.getType());
                slotDescriptor.setIsMaterialized(false);
                context.getColRefToExpr().put(entry, new SlotRef(entry.toString(), slotDescriptor));
            }

            
            List<ScalarOperator> predicates = Utils.extractConjuncts(node.getPredicate());
            ScalarOperatorToExpr.FormatterContext formatterContext =
                    new ScalarOperatorToExpr.FormatterContext(context.getColRefToExpr());

            for (ScalarOperator predicate : predicates) {
                scanNode.getConjuncts().add(ScalarOperatorToExpr.buildExecExpression(predicate, formatterContext));
            }

            tupleDescriptor.computeMemLayout();

            
            setUnUsedOutputColumns(node, scanNode, predicates, referenceTable);
            scanNode.setIsSortedByKeyPerTablet(node.needSortedByKeyPerTablet());

            
            scanNode.setIsPreAggregation(node.isPreAggregation(), node.getTurnOffReason());
            scanNode.setDictStringIdToIntIds(node.getDictStringIdToIntIds());
            scanNode.updateAppliedDictStringColumns(node.getGlobalDicts().stream().
                    map(entry -> entry.first).collect(Collectors.toSet()));

            List<ColumnRefOperator> bucketColumns = getShuffleColumns(node.getDistributionSpec());
            boolean useAllBucketColumns =
                    bucketColumns.stream().allMatch(c -> node.getColRefToColumnMetaMap().containsKey(c));
            if (useAllBucketColumns) {
                List<Expr> bucketExprs = bucketColumns.stream()
                        .map(e -> ScalarOperatorToExpr.buildExecExpression(e,
                                new ScalarOperatorToExpr.FormatterContext(context.getColRefToExpr())))
                        .collect(Collectors.toList());
                scanNode.setBucketExprs(bucketExprs);
                scanNode.setBucketColumns(bucketColumns);
            }

            context.getScanNodes().add(scanNode);
            PlanFragment fragment =
                    new PlanFragment(context.getNextFragmentId(), scanNode, DataPartition.RANDOM);
            fragment.setQueryGlobalDicts(node.getGlobalDicts());
            context.getFragments().add(fragment);
            return fragment;
        }

Line commented on: Preconditions.checkState(selectTabletIds != null && !selectTabletIds.isEmpty());

Revised code:
public PlanFragment visitPhysicalOlapScan(OptExpression optExpr, ExecPlan context) {
            PhysicalOlapScanOperator node = (PhysicalOlapScanOperator) optExpr.getOp();

            OlapTable referenceTable = (OlapTable) node.getTable();
            context.getDescTbl().addReferencedTable(referenceTable);
            TupleDescriptor tupleDescriptor = context.getDescTbl().createTupleDescriptor();
            tupleDescriptor.setTable(referenceTable);

            OlapScanNode scanNode = new OlapScanNode(context.getNextNodeId(), tupleDescriptor, "OlapScanNode");
            scanNode.setLimit(node.getLimit());
            scanNode.computeStatistics(optExpr.getStatistics());

            
            try {
                scanNode.updateScanInfo(node.getSelectedPartitionId(),
                        node.getSelectedTabletId(),
                        node.getSelectedIndexId());
                long selectedIndexId = node.getSelectedIndexId();
                long totalTabletsNum = 0;
                
                
                long localBeId = -1;
                if (Config.enable_local_replica_selection) {
                    localBeId = GlobalStateMgr.getCurrentSystemInfo()
                            .getBackendIdByHost(FrontendOptions.getLocalHostAddress());
                }

                List<Long> selectedNonEmptyPartitionIds = node.getSelectedPartitionId().stream().filter(p -> {
                    List<Long> selectTabletIds = scanNode.getPartitionToScanTabletMap().get(p);
                    return selectTabletIds != null && !selectTabletIds.isEmpty();
                }).collect(Collectors.toList());
                scanNode.setSelectedPartitionIds(selectedNonEmptyPartitionIds);
                for (Long partitionId : scanNode.getSelectedPartitionIds()) {
                    List<Long> selectTabletIds = scanNode.getPartitionToScanTabletMap().get(partitionId);
                    Preconditions.checkState(selectTabletIds != null && !selectTabletIds.isEmpty());
                    final Partition partition = referenceTable.getPartition(partitionId);
                    final MaterializedIndex selectedTable = partition.getIndex(selectedIndexId);
                    List<Long> allTabletIds = selectedTable.getTabletIdsInOrder();
                    Map<Long, Integer> tabletId2BucketSeq = Maps.newHashMap();
                    for (int i = 0; i < allTabletIds.size(); i++) {
                        tabletId2BucketSeq.put(allTabletIds.get(i), i);
                    }
                    totalTabletsNum += selectedTable.getTablets().size();
                    scanNode.setTabletId2BucketSeq(tabletId2BucketSeq);
                    List<Tablet> tablets =
                            selectTabletIds.stream().map(selectedTable::getTablet).collect(Collectors.toList());
                    scanNode.addScanRangeLocations(partition, selectedTable, tablets, localBeId);
                }
                scanNode.setTotalTabletsNum(totalTabletsNum);
            } catch (UserException e) {
                throw new StarRocksPlannerException(
                        "Build Exec OlapScanNode fail, scan info is invalid," + e.getMessage(),
                        INTERNAL_ERROR);
            }

            
            for (Map.Entry<ColumnRefOperator, Column> entry : node.getColRefToColumnMetaMap().entrySet()) {
                SlotDescriptor slotDescriptor =
                        context.getDescTbl().addSlotDescriptor(tupleDescriptor, new SlotId(entry.getKey().getId()));
                slotDescriptor.setColumn(entry.getValue());
                slotDescriptor.setIsNullable(entry.getValue().isAllowNull());
                slotDescriptor.setIsMaterialized(true);
                context.getColRefToExpr().put(entry.getKey(), new SlotRef(entry.getKey().toString(), slotDescriptor));
            }

            for (ColumnRefOperator entry : node.getGlobalDictStringColumns()) {
                SlotDescriptor slotDescriptor =
                        context.getDescTbl().addSlotDescriptor(tupleDescriptor, new SlotId(entry.getId()));
                slotDescriptor.setIsNullable(entry.isNullable());
                slotDescriptor.setType(entry.getType());
                slotDescriptor.setIsMaterialized(false);
                context.getColRefToExpr().put(entry, new SlotRef(entry.toString(), slotDescriptor));
            }

            
            List<ScalarOperator> predicates = Utils.extractConjuncts(node.getPredicate());
            ScalarOperatorToExpr.FormatterContext formatterContext =
                    new ScalarOperatorToExpr.FormatterContext(context.getColRefToExpr());

            for (ScalarOperator predicate : predicates) {
                scanNode.getConjuncts().add(ScalarOperatorToExpr.buildExecExpression(predicate, formatterContext));
            }

            tupleDescriptor.computeMemLayout();

            
            setUnUsedOutputColumns(node, scanNode, predicates, referenceTable);
            scanNode.setIsSortedByKeyPerTablet(node.needSortedByKeyPerTablet());

            
            scanNode.setIsPreAggregation(node.isPreAggregation(), node.getTurnOffReason());
            scanNode.setDictStringIdToIntIds(node.getDictStringIdToIntIds());
            scanNode.updateAppliedDictStringColumns(node.getGlobalDicts().stream().
                    map(entry -> entry.first).collect(Collectors.toSet()));

            List<ColumnRefOperator> bucketColumns = getShuffleColumns(node.getDistributionSpec());
            boolean useAllBucketColumns =
                    bucketColumns.stream().allMatch(c -> node.getColRefToColumnMetaMap().containsKey(c));
            if (useAllBucketColumns) {
                List<Expr> bucketExprs = bucketColumns.stream()
                        .map(e -> ScalarOperatorToExpr.buildExecExpression(e,
                                new ScalarOperatorToExpr.FormatterContext(context.getColRefToExpr())))
                        .collect(Collectors.toList());
                scanNode.setBucketExprs(bucketExprs);
                scanNode.setBucketColumns(bucketColumns);
            }

            context.getScanNodes().add(scanNode);
            PlanFragment fragment =
                    new PlanFragment(context.getNextFragmentId(), scanNode, DataPartition.RANDOM);
            fragment.setQueryGlobalDicts(node.getGlobalDicts());
            context.getFragments().add(fragment);
            return fragment;
        }