github-actions[bot] commented on code in PR #70408:
URL: https://github.com/apache/doris/pull/70408#discussion_r4676233814
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/VariantType.java:
##########
@@ -130,14 +136,41 @@ public DataType conversion() {
.collect(Collectors.toList()),
variantMaxSubcolumnsCount, enableTypedPathsToSparse,
variantMaxSparseColumnStatisticsSize,
variantSparseHashShardCount,
enableVariantDocMode,
variantDocMaterializationMinRows,
- variantDocShardCount, enableNestedGroup);
+ variantDocShardCount, enableNestedGroup,
variantSerializeType);
+ }
+
+ /** This type with the given serialize type, as a new instance. */
+ public VariantType withSerializeType(TVariantSerializeType serializeType) {
+ return new VariantType(predefinedFields, variantMaxSubcolumnsCount,
enableTypedPathsToSparse,
+ variantMaxSparseColumnStatisticsSize,
variantSparseHashShardCount, enableVariantDocMode,
+ variantDocMaterializationMinRows, variantDocShardCount,
enableNestedGroup, serializeType);
+ }
+
+ /** This type with the given max subcolumns count, as a new instance. */
+ public VariantType withMaxSubcolumnsCount(int maxSubcolumnsCount) {
+ return new VariantType(predefinedFields, maxSubcolumnsCount,
enableTypedPathsToSparse,
+ variantMaxSparseColumnStatisticsSize,
variantSparseHashShardCount, enableVariantDocMode,
+ variantDocMaterializationMinRows, variantDocShardCount,
enableNestedGroup, variantSerializeType);
+ }
+
+ /**
+ * Resolves a VARIANT type for a newly created table/MV column. Unbound
compute placeholders
+ * ({@link #INSTANCE} or {@link ConnectorComputeVariantType}) carry no
storage limit, so they
+ * adopt the default subcolumn limit alongside V2; types with an explicit
limit keep it.
+ */
+ public VariantType forNewTableColumn(DataType rawType, boolean isSubPath,
int defaultMaxSubcolumnsCount) {
+ VariantType result = this.withSerializeType(TVariantSerializeType.V2);
+ if (isSubPath || rawType == INSTANCE || rawType instanceof
ConnectorComputeVariantType) {
+ result = result.withMaxSubcolumnsCount(defaultMaxSubcolumnsCount);
Review Comment:
[P2] Keep NestedGroup subpaths on a representable storage type
For an empty, nonescaped NestedGroup source without templates, set
`disable_nereids_rules='PRUNE_EMPTY_PARTITION'` and CTAS `SELECT k,
v['profile'] AS pv FROM ng_src`. Subpath pruning leaves `Project(k, pv) ->
Scan(ng_src, v[profile])`; the subpath slot retains the parent's NG=true/count0
type. This line changes its count to2048 while keeping NG enabled. The zero-row
CTAS succeeds because neither sink opens a segment writer, so the ordinary
target persists NG=true/count2048. Its printed NG-only type parses as count0,
and a comment-only `MODIFY COLUMN pv` using that type fails `Can not change
variant max subcolumns count`; explicitly restating count2048 is also rejected
by the parser's NG/count constraint. Preserve count0 when retaining NG, or
normalize the inferred subpath to an ordinary type, and cover empty CTAS plus
MODIFY.
##########
fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPlanUtil.java:
##########
@@ -518,7 +521,20 @@ public static List<ColumnDefinition> generateColumns(Plan
plan, ConnectContext c
*/
public static DataType getDataType(Slot s, int i, ConnectContext ctx,
String partitionCol,
Set<String> distributionColumnNames) {
- DataType dataType = s.getDataType().conversion();
+ DataType rawType = s.getDataType();
+ DataType dataType = rawType.conversion();
+ boolean managedTableColumn = s instanceof SlotReference
+ && ((SlotReference) s).getOriginalColumn().isPresent()
+ && ((SlotReference) s).getSubPath().isEmpty()
+ && ((SlotReference)
s).getOriginalTable().filter(TableIf::isManagedTable).isPresent();
+ if (dataType instanceof VariantType && !managedTableColumn) {
+ // A VARIANT the query computes (parse_to_variant, a sub path,
coalesce...) or reads from an
+ // external table/TVF is a new column, as in CTAS. A managed table
VARIANT column keeps its type.
+ int defaultMaxSubcolumnsCount =
LogicalPlanBuilder.getVariantDefaults(ctx)
+ .getDefaultVariantMaxSubcolumnsCount();
Review Comment:
[P2] Preserve the inferred VARIANT count during MV reanalysis
With `enable_debug_points=true`, global count 2048 and `SET
debug_variant_max_subcolumns_count=3`, an async MV over `Project(k,
parse_to_variant(s) AS pv) -> Scan(src)` stores `pv` as V2/count3. This setting
is absent from `affectQueryResultInPlanFields`, so `createMTMVContext` restores
a fresh default2048 (or an independently fuzzed count). An unrelated `ALTER
TABLE src ADD COLUMN unused INT` then makes `invalidateMvUnlessQueryHolds`
compare V2/count3 against V2/count2048, mark the valid MV `SCHEMA_CHANGE`, and
block its next refresh. The V1/count0 normalization does not cover this
current-V2 case. Preserve the resolved count across internal contexts, or keep
a changed inference default from becoming a base-schema change; cover unrelated
ALTER followed by refresh. This differs from the fixed historical
inactive-shard comparison and creator golden pins.
--
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]