924060929 commented on code in PR #69995:
URL: https://github.com/apache/doris/pull/69995#discussion_r4581750686


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateTableCommand.java:
##########
@@ -181,6 +183,9 @@ public void validateCreateTableAsSelect(ConnectContext ctx, 
LogicalPlan query) {
         for (int i = 0; i < slots.size(); i++) {
             Slot s = slots.get(i);
             DataType dataType = s.getDataType().conversion();
+            if (dataType instanceof VariantType) {
+                dataType = ((VariantType) dataType).withoutPredefinedFields();

Review Comment:
   [P2] Reconcile inferred NestedGroup with the inherited CTAS encoding
   
   `withoutPredefinedFields()` retains the source column's 
`enableNestedGroup=true`, but the later `inheritVariantEscapeDotsInKeys(..., 
false)` independently enables escaping when **any** source table is escaped, 
including an INT-only join input. This makes CTAS infer an invalid target 
schema even though the user did not request either target storage setting.
   
   For a legacy `legacy(k INT, v 
VARIANT<PROPERTIES('variant_enable_nested_group'='true')>)` and an escaped 
`escaped_ids(k INT)` table, this fails during FE table creation:
   
   ```sql
   CREATE TABLE dst DISTRIBUTED BY HASH(k) BUCKETS 1
   PROPERTIES('replication_num'='1') AS
   SELECT l.k, l.v FROM legacy l JOIN escaped_ids r ON l.k = r.k;
   ```
   
   I reproduced this at the current head with `run-fe-ut.sh`: CTAS from 
`legacy` alone succeeds and preserves NestedGroup; the same join with an 
explicit target `variant_escape_dots_in_keys=false` succeeds; the automatically 
inherited policy fails with `Escaped tables do not support NestedGroup`. The 
session NestedGroup default was already false, so changing that default does 
not resolve this case.
   
   Please resolve the target table policy before normalizing the inferred 
target VARIANT storage options, and make that normalization compatible with the 
selected encoding while leaving the source expression type unchanged. The 
existing final schema validation should remain. Add coverage for a NestedGroup 
source joined to an escaped INT-only table.



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