Skip to content

Conversation

@arnaud-lacurie
Copy link
Collaborator

@arnaud-lacurie arnaud-lacurie commented Nov 16, 2025

Implements validation when creating named structs inline (e.g., STRUCT STRUCT_1(...))
to ensure compatibility with schema-defined types. The validation:

  1. Searches through schema tables to find struct type definitions
  2. Validates field count matches between inline construction and schema definition
  3. Validates each field type is compatible with the schema
  4. Throws CANNOT_CONVERT_TYPE error for type mismatches

This is built on top of #3753

This commit implements a solution for GitHub issue FoundationDB#3743 where struct type
metadata (type names like "STRUCT_1", "STRUCT_2") was getting lost during
query execution, especially in continuations.

**Problem:**
When executing queries that return struct types, ResultSetMetaData would return
UUID-based names (like "id...") instead of proper struct type names. This affected:
- Star expansion queries (SELECT * FROM table)
- Nested star queries (SELECT (*) FROM table)
- Direct struct projections (SELECT struct_column FROM table)
- Query continuations (EXECUTE CONTINUATION)

**Root Cause:**
1. Semantic analysis produces correct DataTypes with struct names ("STRUCT_1", etc.)
2. Cascades planner Type.Record loses struct names during optimization (becomes null)
3. executePhysicalPlan() previously relied only on planner types → UUID generation
4. Continuations had no semantic type info → always generated UUIDs

**Solution - Hybrid Approach:**

Merge semantic type structure with planner field names:
- Field names from planner Type.Record (handles aliases, star expansion, "_0" naming)
- Type structure from semantic DataTypes (preserves "STRUCT_1", "STRUCT_2")
- Additional enrichment from RecordMetaData descriptors for nested types
Implements validation when creating named structs inline (e.g., STRUCT STRUCT_1(...))
to ensure compatibility with schema-defined types. The validation:

1. Searches through schema tables to find struct type definitions
2. Validates field count matches between inline construction and schema definition
3. Validates each field type is compatible with the schema
4. Throws CANNOT_CONVERT_TYPE error for type mismatches
@arnaud-lacurie arnaud-lacurie added the bug fix Change that fixes a bug label Nov 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix Change that fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant