Skip to content

Support compatible type promotion in INSERT INTO ... SELECT - #19414

Open
V-Max wants to merge 1 commit into
apache:masterfrom
V-Max:feat/insert-select-compatible-type-promotion
Open

V-Max wants to merge 1 commit into
apache:masterfrom
V-Max:feat/insert-select-compatible-type-promotion

Conversation

@V-Max

@V-Max V-Max commented Nov 26, 2026

Copy link
Copy Markdown

Description

INSERT INTO ... SELECT previously required the query's output types to
exactly match the target table's column types: typesMatchForInsert used a
strict Type#equals check, so a compatible combination such as an INT32
source column into an INT64 table column was rejected, even though inserting
literal values of compatible types is allowed.

This PR relaxes the check:

  • typesMatchForInsert now accepts a query type that is compatible with the
    table column type (TSDataType#isCompatible), the same rules used by the
    tablet insert path. Non-scalar types (ROW, VECTOR, OBJECT, UNKNOWN) still
    require an exact match.
  • TableInsertTabletStatementGenerator converts each query result column to
    the table column type before building the tablet: numeric writers widen from
    the original column, binary types are converted via Column#convertTo, and
    all-null columns pass through unchanged.

Tests

  • Unit: InsertIntoQueryTest, TableInsertTabletStatementGeneratorTest
  • Integration: IoTDBInsertQueryIT (compatible-type INSERT INTO ... SELECT cases)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant