englefly commented on code in PR #71006:
URL: https://github.com/apache/doris/pull/71006#discussion_r4734828959


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateTableInfo.java:
##########
@@ -499,6 +499,12 @@ public void validate(ConnectContext ctx) {
                 throw new AnalysisException("Disable to create table with 
`DECIMAL` type columns,"
                         + "please use `DECIMALV3`.");
             }
+            DataType type = columnDef.getType();
+            if (type instanceof VariantType
+                    && ((VariantType) type).hasDecimal256Template()) {

Review Comment:
   [P2] Limit the storage-template check to Doris OLAP tables
   
   With `enable_decimal256=true`, a `CREATE TABLE` in an Iceberg catalog using 
format version 3 and Parquet can currently declare `payload 
VARIANT<'amount':DECIMAL(39,2)>`. The DDL converter sends a plain `VARIANT` to 
the connector, and Iceberg stores its native Variant type without the Doris 
path template. This guard now rejects that DDL for all catalogs. Can we gate 
the check on `targetIsInternalCatalog` and preserve the Iceberg create path?
   
   [Connector type 
conversion](https://github.com/apache/doris/blob/23e9a67f6c5ea41530f3876528b9d1c6ba7b5f4c/fe/fe-core/src/main/java/org/apache/doris/datasource/connector/converter/ConnectorColumnConverter.java#L253-L280)
 · [Iceberg schema 
conversion](https://github.com/apache/doris/blob/23e9a67f6c5ea41530f3876528b9d1c6ba7b5f4c/fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergSchemaBuilder.java#L160-L163)



##########
regression-test/suites/variant_p0/v2/variant_decimal256_storage_error.groovy:
##########
@@ -19,80 +19,18 @@ suite("variant_decimal256_storage_error", 
"p0,nonConcurrent") {
     sql "SET enable_decimal256 = true"
     sql "SET debug_variant_enable_doc_mode = false"
 
-    sql "DROP TABLE IF EXISTS variant_decimal256_materialized"
-    sql """
-        CREATE TABLE variant_decimal256_materialized (
-            id INT,
-            var VARIANT<
-                'decimal256_': DECIMAL(76, 2),
-                PROPERTIES(
-                    "variant_max_subcolumns_count" = "1",
-                    "variant_enable_typed_paths_to_sparse" = "false")
-            >
-        ) ENGINE = OLAP
-        DUPLICATE KEY(id)
-        DISTRIBUTED BY HASH(id) BUCKETS 1
-        PROPERTIES("replication_num" = "1")
-    """
-    sql """
-        INSERT INTO variant_decimal256_materialized VALUES
-            (1, parse_to_variant('{"decimal256_":"123.45","hot":1}')),
-            (2, parse_to_variant('{"hot":2}'))
-    """
-    sql "SYNC"
-    test {
-        sql "SELECT var FROM variant_decimal256_materialized ORDER BY id"
-        exception "Conversion from Decimal256 materialized storage column to 
Variant V2 is not supported"
-    }
-
-    sql "DROP TABLE IF EXISTS variant_decimal256_sparse"
-    sql """
-        CREATE TABLE variant_decimal256_sparse (
-            id INT,
-            var VARIANT<
-                'decimal256_': DECIMAL(76, 2),
-                PROPERTIES(
-                    "variant_max_subcolumns_count" = "1",
-                    "variant_enable_typed_paths_to_sparse" = "true")
-            >
-        ) ENGINE = OLAP
-        DUPLICATE KEY(id)
-        DISTRIBUTED BY HASH(id) BUCKETS 1
-        PROPERTIES("replication_num" = "1")
-    """
-    sql """
-        INSERT INTO variant_decimal256_sparse VALUES
-            (1, parse_to_variant('{"decimal256_":"123.45","hot":1}')),
-            (2, parse_to_variant('{"hot":2}'))
-    """
-    sql "SYNC"
-    test {
-        sql "SELECT var FROM variant_decimal256_sparse ORDER BY id"
-        exception "Conversion from Decimal256 storage cell to Variant V2 is 
not supported"
-    }
-
-    sql "DROP TABLE IF EXISTS variant_decimal256_array_materialized"
-    sql """
-        CREATE TABLE variant_decimal256_array_materialized (
-            id INT,
-            var VARIANT<
-                'array_decimal256_': ARRAY<DECIMAL(76, 2)>,
-                PROPERTIES(
-                    "variant_max_subcolumns_count" = "1",
-                    "variant_enable_typed_paths_to_sparse" = "false")
-            >
-        ) ENGINE = OLAP
-        DUPLICATE KEY(id)
-        DISTRIBUTED BY HASH(id) BUCKETS 1
-        PROPERTIES("replication_num" = "1")
-    """
-    sql """
-        INSERT INTO variant_decimal256_array_materialized VALUES
-            (1, parse_to_variant('{"array_decimal256_":[1.23,2.34]}'))
-    """
-    sql "SYNC"
-    test {
-        sql "SELECT var FROM variant_decimal256_array_materialized ORDER BY id"
-        exception "Conversion from Decimal256 materialized storage column to 
Variant V2 is not supported"
+    for (def template : ["DECIMAL(76, 2)", "ARRAY<DECIMAL(76, 2)>"]) {

Review Comment:
   [P3] Preserve coverage for reading a legacy Decimal256 array
   
   The new assertions cover DDL rejection. They also replace the only 
regression case that read a materialized `ARRAY<DECIMAL(76,2)>` from an 
existing schema. Legacy tables can still reach that conversion path. The BE 
tests already cover scalar materialized and sparse Decimal256 errors. Could we 
extend `HierarchicalMaterializedDecimal256ReturnsNotSupported` with an array 
case to verify that an element conversion error propagates to the caller?
   
   [Existing materialized-column unit 
test](https://github.com/apache/doris/blob/23e9a67f6c5ea41530f3876528b9d1c6ba7b5f4c/be/test/storage/segment/variant_assembler_legacy_test.cpp#L747-L767)



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateTableInfo.java:
##########
@@ -499,6 +499,12 @@ public void validate(ConnectContext ctx) {
                 throw new AnalysisException("Disable to create table with 
`DECIMAL` type columns,"
                         + "please use `DECIMALV3`.");
             }
+            DataType type = columnDef.getType();
+            if (type instanceof VariantType

Review Comment:
   [P2] Apply the same check when an OLAP table gains a column
   
   With `enable_decimal256=true` and `light_schema_change=true`, `ALTER TABLE t 
ADD COLUMN v VARIANT<'amount':DECIMAL(39,2)>` still reaches 
`ColumnDefinition.validate()` without this guard. The multi-column ADD form 
uses the same validation. Once a row contains `amount`, reading the whole 
VARIANT can still fail during the BE conversion to Variant V2. This path 
already existed on the base branch. Can we share the check between OLAP CREATE 
TABLE and ADD COLUMN and add rejection coverage for both entry points?
   
   [ADD COLUMN 
validation](https://github.com/apache/doris/blob/23e9a67f6c5ea41530f3876528b9d1c6ba7b5f4c/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AddColumnOp.java#L237-L243)
 · [BE materialized-value 
conversion](https://github.com/apache/doris/blob/23e9a67f6c5ea41530f3876528b9d1c6ba7b5f4c/be/src/storage/segment/variant/v2/variant_assembler_value.cpp#L119-L149)



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