|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +// An equality between two columns does not let a MATCH on one column be copied to the other: |
| 19 | +// MATCH depends on the inverted index of its column, and a copy would add to score(). |
| 20 | +suite("infer_match_predicate") { |
| 21 | + // c2 has an index without a parser, so MATCH on c2 only matches a whole value. |
| 22 | + sql "DROP TABLE IF EXISTS infer_match_predicate_parser" |
| 23 | + sql """ |
| 24 | + CREATE TABLE infer_match_predicate_parser ( |
| 25 | + id INT, |
| 26 | + c1 TEXT, |
| 27 | + c2 TEXT, |
| 28 | + INDEX idx_c1 (c1) USING INVERTED PROPERTIES ("parser" = "english"), |
| 29 | + INDEX idx_c2 (c2) USING INVERTED |
| 30 | + ) DUPLICATE KEY(id) DISTRIBUTED BY HASH(id) BUCKETS 1 |
| 31 | + PROPERTIES ("replication_num" = "1") |
| 32 | + """ |
| 33 | + sql "INSERT INTO infer_match_predicate_parser VALUES (1, 'apple red', 'apple red'), (2, 'banana', 'banana')" |
| 34 | + order_qt_different_index """ |
| 35 | + SELECT id FROM infer_match_predicate_parser |
| 36 | + WHERE c1 = c2 AND (c1 MATCH_ANY 'apple' OR c1 MATCH_ANY 'pear') |
| 37 | + """ |
| 38 | + |
| 39 | + sql "DROP TABLE IF EXISTS infer_match_predicate_score" |
| 40 | + sql """ |
| 41 | + CREATE TABLE infer_match_predicate_score ( |
| 42 | + id INT, |
| 43 | + c1 TEXT, |
| 44 | + c2 TEXT, |
| 45 | + INDEX idx_c1 (c1) USING INVERTED PROPERTIES ("parser" = "english"), |
| 46 | + INDEX idx_c2 (c2) USING INVERTED PROPERTIES ("parser" = "english") |
| 47 | + ) DUPLICATE KEY(id) DISTRIBUTED BY HASH(id) BUCKETS 1 |
| 48 | + PROPERTIES ("replication_num" = "1") |
| 49 | + """ |
| 50 | + sql """ |
| 51 | + INSERT INTO infer_match_predicate_score VALUES |
| 52 | + (1, 'apple red', 'apple red'), (2, 'apple green', 'apple green'), (3, 'banana yellow', 'banana yellow') |
| 53 | + """ |
| 54 | + order_qt_score """ |
| 55 | + SELECT id, score() AS s FROM infer_match_predicate_score |
| 56 | + WHERE c1 = c2 AND (c1 MATCH_ANY 'apple' OR c1 MATCH_ANY 'pear') ORDER BY s DESC LIMIT 10 |
| 57 | + """ |
| 58 | + order_qt_minimum_score """ |
| 59 | + SELECT id, score() AS s FROM infer_match_predicate_score |
| 60 | + WHERE c1 = c2 AND (c1 MATCH_ANY 'apple' OR c1 MATCH_ANY 'pear') AND score() > 0.6 |
| 61 | + ORDER BY s DESC LIMIT 10 |
| 62 | + """ |
| 63 | +} |
0 commit comments