diff --git a/dingo-calcite/src/main/java/io/dingodb/calcite/DingoParser.java b/dingo-calcite/src/main/java/io/dingodb/calcite/DingoParser.java index 3d606db84..4874dd3e9 100644 --- a/dingo-calcite/src/main/java/io/dingodb/calcite/DingoParser.java +++ b/dingo-calcite/src/main/java/io/dingodb/calcite/DingoParser.java @@ -222,7 +222,9 @@ public RelRoot convert(@NonNull SqlNode sqlNode, boolean needsValidation) { HintStrategyTable hintStrategyTable = new HintStrategyTable.Builder() .hintStrategy("vector_pre", hintPredicate) .hintStrategy(HybridSearchTable.HINT_NAME, hintPredicate) - .hintStrategy("disable_index", hintPredicate).build(); + .hintStrategy("disable_index", hintPredicate) + .hintStrategy("document_pre", hintPredicate) + .build(); SqlToRelConverter sqlToRelConverter = new DingoSqlToRelConverter( ViewExpanders.simpleContext(cluster), sqlValidator, diff --git a/dingo-calcite/src/main/java/io/dingodb/calcite/rule/DingoDocumentProjectRule.java b/dingo-calcite/src/main/java/io/dingodb/calcite/rule/DingoDocumentProjectRule.java index 73d3178e2..e169419c9 100644 --- a/dingo-calcite/src/main/java/io/dingodb/calcite/rule/DingoDocumentProjectRule.java +++ b/dingo-calcite/src/main/java/io/dingodb/calcite/rule/DingoDocumentProjectRule.java @@ -19,9 +19,11 @@ import io.dingodb.calcite.DingoTable; import io.dingodb.calcite.grammar.SqlUserDefinedOperators; import io.dingodb.calcite.rel.LogicalDingoDocument; +import io.dingodb.common.table.HybridSearchTable; import io.dingodb.common.type.TupleMapping; import org.apache.calcite.plan.RelOptRuleCall; import org.apache.calcite.plan.RelRule; +import org.apache.calcite.rel.hint.RelHint; import org.apache.calcite.rel.logical.LogicalProject; import org.apache.calcite.rel.rules.SubstitutionRule; import org.apache.calcite.rex.RexCall; @@ -92,6 +94,15 @@ select id, distance from xx where not in (sub item size > 20) -> generate same selectedColumns.sort(Comparator.naturalOrder()); Mapping mapping = Mappings.target(selectedColumns, document.getRowType().getFieldCount()); + List hints = document.hints; + if (project.getHints() != null) { + for (RelHint hint: project.getHints()) { + if (hint.hintName.equalsIgnoreCase(HybridSearchTable.HINT_NAME)) { + hints.add(hint); + } + } + } + LogicalDingoDocument newDocument = new LogicalDingoDocument( document.getCluster(), document.getTraitSet(),