github-actions[bot] commented on code in PR #69761:
URL: https://github.com/apache/doris/pull/69761#discussion_r4438448080


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/IndexDefinition.java:
##########
@@ -562,6 +572,66 @@ public Map<String, String> getProperties() {
         return properties;
     }
 
+    public boolean isVariantValuesIndex() {
+        return indexType == IndexType.INVERTED && 
InvertedIndexProperties.isVariantValuesIndex(properties);
+    }
+
+    private void validateVariantValuesIndex(DataType columnType,
+            TInvertedIndexFileStorageFormat invertedIndexFileStorageFormat) {
+        String scope = 
properties.get(InvertedIndexUtil.VARIANT_INDEX_SCOPE_KEY);
+        if (scope == null) {
+            return;
+        }
+        if (!isVariantValuesIndex()) {
+            throw new AnalysisException("variant_index_scope must be values, 
found: " + scope);
+        }
+        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.getEnableNestedGroup()) {
+            throw new AnalysisException("VARIANT values index does not support 
NestedGroup");
+        }
+        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) {
+            throw new AnalysisException(
+                    "VARIANT values index requires 
inverted_index_storage_format=SNII");
+        }
+        if 
("true".equals(properties.get(InvertedIndexUtil.INVERTED_INDEX_SUPPORT_PHRASE_KEY)))
 {
+            throw new AnalysisException("VARIANT values index does not support 
support_phrase=true");
+        }
+        String analyzer = 
properties.getOrDefault(InvertedIndexUtil.INVERTED_INDEX_ANALYZER_NAME_KEY, 
"").trim();
+        if 
(InvertedIndexProperties.INVERTED_INDEX_PARSER_NONE.equalsIgnoreCase(
+                InvertedIndexProperties.getInvertedIndexParser(properties))
+                && (analyzer.isEmpty()
+                    || 
InvertedIndexProperties.INVERTED_INDEX_PARSER_NONE.equalsIgnoreCase(analyzer))) 
{
+            throw new AnalysisException("VARIANT values index requires a 
parser or analyzer with tokenization");
+        }
+        if (!analyzer.isEmpty()
+                && 
!IndexPolicy.BUILTIN_ANALYZERS.contains(InvertedIndexUtil.resolveAnalyzerName(analyzer)))
 {
+            throw new AnalysisException("VARIANT values index supports only 
built-in parsers and analyzers");
+        }
+        if 
(properties.containsKey(InvertedIndexUtil.INVERTED_INDEX_PARSER_FIELD_PATTERN_KEY))
 {
+            throw new AnalysisException("VARIANT values index does not support 
field_pattern");
+        }
+    }
+
+    private static boolean containsDecimal256(DataType type) {
+        if (type instanceof DecimalV3Type) {
+            return ((DecimalV3Type) type).getPrecision() > 38;
+        }
+        if (type instanceof ArrayType) {

Review Comment:
   [P2] Reject Decimal256 nested in STRUCT/MAP predefined paths. 
`containsDecimal256()` only recurses through `ArrayType`, so 
`VARIANT<'obj':STRUCT<'wide':DECIMAL(76,2)>>` (and MAP/nested variants) passes 
the values-index DDL check. During insert, 
`VariantAssembler::append_materialized_value` reaches the nested 
`TYPE_DECIMAL256` and returns `NotSupported`, making a legal table fail to 
ingest solely because the values index is present. Recurse through `StructType` 
and `MapType` as well, and add a nested-container regression.



-- 
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