Repository navigation
Conversation
…est-only and fix CREATE TABLE LIKE of VARIANT apache#70501 Cherry-picked from apache#70501 ### What problem does this PR solve? Issue Number: None Related PR: apache#70501 Problem Summary: CREATE TABLE LIKE prints the source table as DDL text (the SHOW CREATE TABLE text) and parses it again. The text of a VARIANT column omits `variant_enable_doc_mode` and `variant_enable_nested_group` when they are false, and the parser fills every property missing from a DDL from the `default_variant_*` session variables. So the copy depended on the session that ran the statement: ```sql CREATE TABLE src (id INT, v VARIANT<'a.b':INT, PROPERTIES("variant_max_subcolumns_count"="3")>) DUPLICATE KEY(id) DISTRIBUTED BY HASH(id) BUCKETS 1 PROPERTIES("replication_num"="1"); SET default_variant_enable_doc_mode = true; CREATE TABLE dst LIKE src; SHOW CREATE TABLE dst; -- before: v variant<MATCH_NAME 'a.b':int,PROPERTIES ("variant_enable_doc_mode" = "true", -- "variant_doc_materialization_min_rows" = "0","variant_doc_hash_shard_count" = "64")> -- (doc mode, the subcolumn count 3 is gone) -- after: the SET fails; with the default session v is as in src ``` The `default_variant_*` session variables exist for the fuzzy tests only. Fix: 1. The parser reads the `default_variant_*` session variables only when the FE runs with `enable_debug_points = true`, which every regression pipeline and docker test cluster sets. Otherwise, and without a session, the properties a DDL leaves out take the built-in values (a parse without a session used its own constants before, such as subcolumn count 0 and nested group on). It does not use the global values either: a value set with SET GLOBAL on an older version still loads from an image. So a DDL text, such as the one CREATE TABLE LIKE prints and parses, creates the same column in every session. 2. The variables are invisible in SHOW VARIABLES, and SET / SET GLOBAL / SET_VAR of them fails unless debug points are enabled. Users state VARIANT properties in the column definition. 3. A nested group VARIANT type prints only `variant_enable_nested_group`, as a doc mode type prints only the doc mode properties. With debug points enabled, CREATE TABLE LIKE still follows the session; a test that copies a VARIANT table sets the variables first, as the existing suites do. ### Release note The `default_variant_*` session variables (`default_variant_max_subcolumns_count`, `default_variant_enable_typed_paths_to_sparse`, `default_variant_max_sparse_column_statistics_size`, `default_variant_sparse_hash_shard_count`, `default_variant_enable_doc_mode`, `default_variant_doc_materialization_min_rows`, `default_variant_doc_hash_shard_count`, `default_variant_enable_nested_group`) can no longer be set and are not shown by SHOW VARIABLES; set the properties in the VARIANT column definition instead. A value set with SET GLOBAL before the upgrade no longer takes effect. CREATE TABLE LIKE copies the VARIANT properties of the source table regardless of the session. Differences from the master commit, all because branch-4.2 lacks later refactors: - `SessionVariable` uses `VariableMgr.INVISIBLE` (there is no `VarAttrDef`). - `VariableMgrTest` checks `VariableMgr.dump` instead of `VariableMgr.getShownVarContext`, which branch-4.2 does not have. - `CreateTableLikeTest`, `TypeTest` and `VariableMgrTest` are JUnit 4 on branch-4.2, so the new cases use its assertions and helpers. ### Check List (For Author) - Test: Unit Test - CreateTableLikeTest, TypeTest, PropertyAnalyzerTest, NereidsParserTest and VariableMgrTest pass on branch-4.2 (145 cases). The regression suite test_variant_create_table_like was not run on branch-4.2. - Behavior changed: Yes (see the release note) - Does this need documentation: No (cherry picked from commit 0e8b56e) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Contributor
Author
|
run buildall |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-picked from #70501
What problem does this PR solve?
Issue Number: None
Related PR: #70501
Problem Summary:
CREATE TABLE LIKE prints the source table as DDL text (the SHOW CREATE TABLE text) and parses it again. The text of a VARIANT column omits
variant_enable_doc_modeandvariant_enable_nested_groupwhen they are false, and the parser fills every property missing from a DDL from thedefault_variant_*session variables. So the copy depended on the session that ran the statement:The
default_variant_*session variables exist for the fuzzy tests only. Fix:default_variant_*session variables only when the FE runs withenable_debug_points = true, which every regression pipeline and docker test cluster sets. Otherwise, and without a session, the properties a DDL leaves out take the built-in values (a parse without a session used its own constants before, such as subcolumn count 0 and nested group on). It does not use the global values either: a value set with SET GLOBAL on an older version still loads from an image. So a DDL text, such as the one CREATE TABLE LIKE prints and parses, creates the same column in every session.variant_enable_nested_group, as a doc mode type prints only the doc mode properties.With debug points enabled, CREATE TABLE LIKE still follows the session; a test that copies a VARIANT table sets the variables first, as the existing suites do.
Release note
The
default_variant_*session variables(
default_variant_max_subcolumns_count,default_variant_enable_typed_paths_to_sparse,default_variant_max_sparse_column_statistics_size,default_variant_sparse_hash_shard_count,default_variant_enable_doc_mode,default_variant_doc_materialization_min_rows,default_variant_doc_hash_shard_count,default_variant_enable_nested_group) can no longer be set and are not shown by SHOW VARIABLES; set the properties in the VARIANT column definition instead. A value set with SET GLOBAL before the upgrade no longer takes effect. CREATE TABLE LIKE copies the VARIANT properties of the source table regardless of the session.Differences from the master commit, all because branch-4.2 lacks later refactors:
SessionVariableusesVariableMgr.INVISIBLE(there is noVarAttrDef).VariableMgrTestchecksVariableMgr.dumpinstead ofVariableMgr.getShownVarContext, which branch-4.2 does not have.CreateTableLikeTest,TypeTestandVariableMgrTestare JUnit 4 on branch-4.2, so the new cases use its assertions and helpers.Check List (For Author)
(cherry picked from commit 0e8b56e)
Background
What problem does this PR solve?
Issue Number:
Related PR:
PR Type:
Problem Summary:
Details
Testing
Notes for Reviewers
Release note
Check List (For Author)
AI Disclosure