From a2dd9a79da9c8a72a4e94752cd45f01ad4e67eeb Mon Sep 17 00:00:00 2001 From: yz Date: Thu, 10 Oct 2024 06:39:09 +0000 Subject: [PATCH] [feature][dingo-executor] Support text search with hint --- .../src/main/java/io/dingodb/calcite/DingoParser.java | 4 +++- .../calcite/rule/DingoDocumentProjectRule.java | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) 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 3d606db84d..4874dd3e91 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 73d3178e2f..e169419c9d 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(),