Skip to content

IGNITE-28755 SQL Calcite: Fix typeId collisions for autogenerated types#13219

Open
alex-plekhanov wants to merge 3 commits into
apache:masterfrom
alex-plekhanov:ignite-28755
Open

IGNITE-28755 SQL Calcite: Fix typeId collisions for autogenerated types#13219
alex-plekhanov wants to merge 3 commits into
apache:masterfrom
alex-plekhanov:ignite-28755

Conversation

@alex-plekhanov

Copy link
Copy Markdown
Contributor

Thank you for submitting the pull request to the Apache Ignite.

In order to streamline the review of the contribution
we ask you to ensure the following steps have been taken:

The Contribution Checklist

  • There is a single JIRA ticket related to the pull request.
  • The web-link to the pull request is attached to the JIRA ticket.
  • The JIRA ticket has the Patch Available state.
  • The pull request body describes changes that have been made.
    The description explains WHAT and WHY was made instead of HOW.
  • The pull request title is treated as the final commit message.
    The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
  • A reviewer has been mentioned through the JIRA comments
    (see the Maintainers list)
  • The pull request has been checked by the Teamcity Bot and
    the green visa attached to the JIRA ticket (see tab PR Check at TC.Bot - Instance 1 or TC.Bot - Instance 2)

Notes

If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com #ignite channel.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses binary typeId collisions in the Calcite SQL CREATE TABLE flow by detecting collisions against existing marshaller mappings and either (a) regenerating auto-generated type names or (b) rejecting explicitly provided type names that would collide.

Changes:

  • Add collision avoidance loop for auto-generated key/value type names in Calcite DDL handling.
  • Add validation that explicitly provided KEY_TYPE / VALUE_TYPE do not collide with an already-mapped type ID.
  • Add integration tests intended to cover both auto-generated collision resolution and explicit-type collision rejection, and expose a marshaller-context lookup helper.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java Adds resolveClassName helper used by Calcite to detect existing mappings (but currently contains a broken assert condition).
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ddl/DdlCommandHandler.java Regenerates auto-generated type names until no typeId collision is found; validates explicit type names to fail fast on collisions.
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDdlIntegrationTest.java Adds integration tests for auto-generated collision handling and explicit collision rejection (but the collision setup is currently extremely heavy and probabilistic).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java Outdated
alex-plekhanov and others added 2 commits June 11, 2026 08:57
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
String anotherTypeName = ((MarshallerContextImpl)binCtx.marshaller().getContext()).resolveClassName(JAVA_ID, typeId);

if (anotherTypeName == null || anotherTypeName.equals(typeName)
|| binCtx.userTypeName(anotherTypeName).equals(binCtx.userTypeName(typeName)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binCtx.userTypeName(anotherTypeName).equals(binCtx.userTypeName(typeName)) - this branch is not covered by tests ?

}

/** */
private void validateTypeName(String typeName) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What action points do user need to implement if exception will raised ? Seems we need to give a some clue here ?


if (mappedName != null) {
assert mappedName.accepted() : mappedName;
assert !ensureAccepted || mappedName.accepted() : mappedName;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no definition\documentation what ".accepted()" flag mean - thus it`s hard to understand this assertion - can you append some kind of explanation here ?

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.

3 participants