Repository navigation
Conversation
The server accepts type aliases (BIGINT, TEXT, BOOLEAN, DOUBLE PRECISION, ...) and the case-insensitive type names in any letter case, but the parser only knew the canonical names, so such names gave nullptr at the root and a Void column inside a container. The parser now maps the aliases from system.data_type_families, and the case-insensitive families (plus Array, Map, Enum8 and Enum16, which the server also reads in any case), to the canonical name. Names that the server reads case-sensitively (Int64, String, Nullable, Tuple, ...) stay case-sensitive. An alias with several words is read as one name, so INT UNSIGNED is UInt32 and not a field INT of type UNSIGNED. Closes ClickHouse#652
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 193a9ed. Configure here.
| if (!type_->name.empty() && token.type == Token::Name && IsMultiWordAliasPart(type_->name, token.value)) { | ||
| // A word of an alias with several words, e.g. "UNSIGNED" in "INT UNSIGNED". | ||
| type_->name += ' '; | ||
| type_->name += token.value.to_string(); |
There was a problem hiding this comment.
Quoted tuple fields join aliases
Medium Severity
Alias joining appends the next bare word to any name already stored, including a quoted identifier. A quoted tuple field that begins a multi-word alias is absorbed into the type: the field name is dropped, and a shorter integer alias can be chosen instead of standalone SIGNED or UNSIGNED.
Reviewed by Cursor Bugbot for commit 193a9ed. Configure here.
AI review gate — Cursor Bugbot found issues
Unresolved findings (1): What to do:
Re-run the gate with “Re-run jobs” after an approval or a finished review. A push re-runs it automatically. |
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.


CreateColumnByType()only knew the canonical type names. The server also accepts the aliases ofsystem.data_type_families(BIGINT,TEXT,BOOLEAN,DOUBLE PRECISION,INET4, ...) and the case-insensitive type names in any letter case (datetime,decimal(9, 2),DATE,json), so a column could not be made from the type name of the table's own DDL: the root gavenullptr, and a name inside a container gave aVoidcolumn.The parser now resolves a name to the canonical one before it picks the type code and the meta type:
case_insensitive = 1, plusArray,Map,Enum8andEnum16, which the server also reads in any letter case;DOUBLE PRECISION,NATIONAL CHARACTER LARGE OBJECT,INT UNSIGNED, ...) is read as one name. This includes the 14 names that end inSIGNEDorUNSIGNED(see the comment on the issue); without itINT UNSIGNEDwould be a fieldINTof typeUNSIGNED, soUInt64. A name that is not the start of such an alias is still a field name, as inTuple(a Int32).Names that the server reads case-sensitively (
int64,string,nullable(...),tuple(...),lowcardinality(...), ...) are still not accepted, as on the server.Enum,GeometryandDecimal256are not mapped, as the library has no column for them.Tests:
CreateColumnByTypeNameAliasinut/CreateColumnByType_ut.cpp: aliases,SIGNED/UNSIGNEDforms, letter case, and aliases insideNullable,Array,Map,LowCardinalityand namedTuple; plusTypeNameAliasUnknownNamesandBoolAlias.ClientCase.TypeNameAliasesFromTypeNameinut/client_ut.cpp: inserts columns made fromBIGINT,TEXT,INT UNSIGNED,DOUBLE PRECISIONanddatetimeinto a table with those column types and reads the values back.The new tests fail without the change (63 failures). The whole
clickhouse-cpp-utsuite passes against a local server (1139 tests).Fixes #652
Note
Medium Risk
Changes central type-string parsing used by column creation; incorrect alias or tuple-field disambiguation could mis-resolve types at runtime, though behavior is aligned with server rules and heavily tested.
Overview
CreateColumnByType()and the type parser now accept the same type spellings ClickHouse uses in DDL, so columns can be built from names likeBIGINT,TEXT, ordatetimeinstead of only canonical forms likeInt64.The parser in
type_parser.cppresolves identifiers throughGetCanonicalTypeName: server aliases (system.data_type_families), case-insensitive families (Bool,DateTime,Array, …), and multi-word aliases (DOUBLE PRECISION,INT UNSIGNED,NATIONAL CHARACTER LARGE OBJECT) by joining consecutive name tokens when they form a known alias. Case-sensitive names the server rejects (int64,nullable(...), partial alias prefixes) still fail as before.Unit tests cover aliases,
SIGNED/UNSIGNED, casing, nested wrappers, and rejection cases;ClientCase.TypeNameAliasesFromTypeNameround-trips an insert using DDL-style type strings against a matching temporary table.Reviewed by Cursor Bugbot for commit 193a9ed. Bugbot is set up for automated code reviews on this repo. Configure here.