Copilot commented on code in PR #64572: URL: https://github.com/apache/doris/pull/64572#discussion_r3421487442
########## regression-test/suites/variant_p0/schema_change/test_variant_add_drop_nullable_compaction.groovy: ########## @@ -0,0 +1,103 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("test_variant_add_drop_nullable_compaction", "variant_type,nonConcurrent") { + sql "DROP TABLE IF EXISTS test_variant_add_drop_nullable_compaction" + sql "set default_variant_enable_doc_mode = false" + sql """ + CREATE TABLE test_variant_add_drop_nullable_compaction ( + k int, + v variant, + old_v variant + ) + DUPLICATE KEY(k) + DISTRIBUTED BY HASH(k) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1", + "disable_auto_compaction" = "true" + ); + """ + + sql """ + INSERT INTO test_variant_add_drop_nullable_compaction VALUES + (0, '{"a":"old-one"}', '{"gone":"drop-one"}'), + (1, '{"a":"old-two"}', '{"gone":"drop-two"}'); + """ + + sql "ALTER TABLE test_variant_add_drop_nullable_compaction DROP COLUMN old_v" + waitForSchemaChangeDone { + sql """SHOW ALTER TABLE COLUMN WHERE IndexName='test_variant_add_drop_nullable_compaction' ORDER BY createtime DESC LIMIT 1""" + time 600 + } + + sql "ALTER TABLE test_variant_add_drop_nullable_compaction ADD COLUMN v2 variant<'x':string> DEFAULT NULL" + waitForSchemaChangeDone { + sql """SHOW ALTER TABLE COLUMN WHERE IndexName='test_variant_add_drop_nullable_compaction' ORDER BY createtime DESC LIMIT 1""" + time 600 + } + + sql """ + INSERT INTO test_variant_add_drop_nullable_compaction VALUES + (2, '{"a":"new-one"}', '{"x":"added-one"}'), + (3, '{"a":"new-two"}', '{"x":"added-two"}'); + """ + sql "SYNC" + + order_qt_before_compaction """ + SELECT k, cast(v2['x'] as string) + FROM test_variant_add_drop_nullable_compaction + ORDER BY k + """ + + def tabletStats = sql_return_maparray "SHOW TABLETS FROM test_variant_add_drop_nullable_compaction" + assertEquals(1, tabletStats.size()) + def tablet = tabletStats[0] + def (code, out, err) = curl("GET", tablet.CompactionStatus) + assertEquals(0, code) + def tabletStatus = parseJson(out.trim()) + assert tabletStatus.rowsets instanceof List + logger.info("tablet ${tablet.TabletId} rowsets before compaction: ${tabletStatus.rowsets}") + + def rowsetVersions = ((List<String>) tabletStatus.rowsets).collect { rowset -> + def matcher = rowset =~ /\[(\d+)-(\d+)\]/ + assert matcher.find(): "Cannot parse rowset version from ${rowset}" + [matcher.group(1).toInteger(), matcher.group(2).toInteger()] + }.findAll { version -> version[1] >= 2 } + assertTrue(rowsetVersions.size() >= 2, + "Expected at least two data rowsets across add-variant schema change, got ${tabletStatus.rowsets}") + int startVersion = rowsetVersions.first()[0] + int endVersion = rowsetVersions.last()[1] Review Comment: `first()`/`last()` assumes `tabletStatus.rowsets` is already ordered by version. If the BE returns rowsets in a different order, this can pick an incorrect `[startVersion, endVersion]` range and make the compaction forcing flaky. Sorting `rowsetVersions` (e.g., by start then end) before taking first/last would make the test deterministic. ########## be/src/exec/common/variant_util.cpp: ########## @@ -103,6 +103,18 @@ namespace doris::variant_util { +static bool can_ignore_missing_column_for_variant_stats(const TabletColumn& column, + const Status& st) { + if (!st.is<ErrorCode::NOT_FOUND>()) { + return false; + } + if (column.is_nullable()) { + return true; + } + auto default_value = column.default_value(); + return column.has_default_value() && (default_value == "NULL" || default_value == "null"); Review Comment: Minor robustness improvement: `column.default_value()` is evaluated unconditionally even though it’s only needed when `has_default_value()` is true. If `default_value()` can be undefined/expensive when no default exists, this could be problematic. Also, comparing only to \"NULL\"/\"null\" is a bit brittle; consider a case-insensitive check to avoid unexpected casing differences. -- 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]
