eldenmoon commented on code in PR #69761:
URL: https://github.com/apache/doris/pull/69761#discussion_r4431833115


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/BindScoreToOlapScan.java:
##########
@@ -216,6 +216,15 @@ private static void check(List<Plan> path, boolean 
outermost) {
         if (where.stream().noneMatch(conjunct -> 
conjunct.containsType(Match.class, Search.class))) {
             throw new AnalysisException(UNSUPPORTED_SELECT_ERROR);
         }
+        for (Expression conjunct : where) {
+            for (Expression expression : conjunct.<Expression>collect(e -> e 
instanceof Match)) {
+                Match match = (Match) expression;
+                if (match.left().getDataType().isVariantType()) {

Review Comment:
   Fixed in 7234519d70f. The `score()` restriction now applies only when the 
MATCH input is a root slot served by a values index 
(`ExpressionAnalyzer.isVariantRootSlot`, `BindScoreToOlapScan.java:223`); 
`v['a'] MATCH ...` with `score()` keeps master behavior. UT in 
`BindScoreToOlapScanTest`.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/IndexDefinition.java:
##########
@@ -562,6 +583,77 @@ public Map<String, String> getProperties() {
         return properties;
     }
 
+    public boolean isVariantRootIndex() {
+        return indexType == IndexType.INVERTED && 
InvertedIndexUtil.isVariantRootIndex(properties);
+    }
+
+    /**
+     * Validates the user's spelling of a VARIANT root index as given. Both 
spellings of the
+     * scope must individually be the values scope (an invalid one is never 
hidden by a valid
+     * sibling), and only the format version this FE stamps is accepted back, 
so that a SHOW
+     * CREATE TABLE output replays. Canonicalization happens in 
translateToCatalogStyle().
+     */
+    private void validateVariantRootIndex(DataType columnType, KeysType 
keysType,
+            TInvertedIndexFileStorageFormat invertedIndexFileStorageFormat) {
+        String scope = 
properties.get(InvertedIndexUtil.VARIANT_INDEX_SCOPE_KEY);
+        String mode = properties.get(InvertedIndexUtil.VARIANT_INDEX_MODE_KEY);
+        String formatVersion = 
properties.get(InvertedIndexUtil.VARIANT_ROOT_FORMAT_VERSION_KEY);
+        if (scope == null && mode == null) {
+            if (formatVersion != null) {
+                throw new AnalysisException(
+                        "variant_root_format_version requires 
variant_index_scope");
+            }
+            return;
+        }
+        if (scope != null && 
InvertedIndexProperties.normalizeVariantIndexScope(scope) == null) {
+            throw new AnalysisException("variant_index_scope must be values, 
found: " + scope);
+        }
+        if (mode != null && 
InvertedIndexProperties.normalizeVariantIndexScope(mode) == null) {
+            throw new AnalysisException("variant_index_mode must be 
all_values, found: " + mode);
+        }
+        if (!columnType.isVariantType()) {
+            throw new AnalysisException(
+                    "variant_index_scope=values can only be used on VARIANT 
columns");
+        }
+        // Declared Decimal256 can be stored, but full-root assembly cannot 
decode it.
+        // Reject this combination before accepting a table whose legal 
inserts would fail.
+        VariantType variantType = (VariantType) columnType;
+        if (variantType.getPredefinedFields().stream()
+                .anyMatch(field -> containsDecimal256(field.getDataType()))) {
+            throw new AnalysisException("VARIANT values index does not support 
declared Decimal256 paths");
+        }
+        if (invertedIndexFileStorageFormat != 
TInvertedIndexFileStorageFormat.SNII) {

Review Comment:
   Fixed in 7234519d70f. In cloud mode, `ALTER TABLE ... SET 
("partition.inverted_index_storage_format" = "V2"/"V3")` is rejected for a 
table with a values index; switching back to SNII stays allowed 
(`CloudSchemaChangeHandler.java:162`). UT: 
`CloudSchemaChangeHandlerTest.testValuesIndexRequiresSniiForFuturePartitions`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to