Skip to content

Conversation

@Yuqi-Du
Copy link
Contributor

@Yuqi-Du Yuqi-Du commented Oct 16, 2025

Summary

Implements UDT partial projection with precise schema reflection, and adds comprehensive unit + integration tests for both non-UDT and UDT projections (inclusion, exclusion, null handling).

  • This PR also fixes a bug, now, should throw an error when request wants to projection an unknown column or unknown UDT field.

UDT Partial Projection & Schema

Use dot notation for UDT subfields (e.g., {"mainAddress.city": 1}).

  • Top-level include { "mainAddress": 1 }: schema includes all UDT fields (city, country).
  • Subfield include { "mainAddress.city": 1 }: schema includes only city under definition.fields.
  • Top-level include overrides subfield { "mainAddress": 1, "mainAddress.city": 1 }: all UDT fields present.
  • Subfield exclusion { "mainAddress.city": 0 }: schema lists only remaining fields (e.g., country).
  • The subField projection follows the null tradition, only return data is it is not null. (schema is returned though)

Projection schema mirrors exactly the selected (or remaining after exclusion) UDT fields under status.projectionSchema.<udtColumn>.definition.fields.

Testing

  • Selector tests: non-UDT and UDT inclusion/exclusion, subfields, whole UDT.
  • High-level tests: scalars + UDTs (inclusion/exclusion, nulls, numeric/date-time), JSON size checks.
  • Integration tests: Scalars and UDTs; schema asserted for every test (including UDT subfield exclusion).

JSON Examples

Exclude a UDT subfield

{ "mainAddress.city": 0 }
{
  "data": {
    "document": {
      "id": "mike",
      "mainAddress": { "country": "USA" }
    }
  },
  "status": {
    "projectionSchema": {
      "id": { "type": "text" },
      "mainAddress": {
        "type": "userDefined",
        "udtName": "address",
        "definition": {
          "fields": {
            "country": { "type": "text" }
          }
        }
      }
    }
  }
}

Include only a UDT subfield

{ "mainAddress.city": 1 }
{
  "status": {
    "projectionSchema": {
      "mainAddress": {
        "type": "userDefined",
        "udtName": "address",
        "definition": {
          "fields": { "city": { "type": "text" } }
        }
      }
    }
  }
}

Include UDT top-level

{ "mainAddress": 1 }
{
  "status": {
    "projectionSchema": {
      "mainAddress": {
        "type": "userDefined",
        "udtName": "address",
        "definition": {
          "fields": {
            "city": { "type": "text" },
            "country": { "type": "text" }
          }
        }
      }
    }
  }
}

Checklist

  • Manually tested
  • Tests added/updated (unit + integration)
  • Docs/comments updated
  • CLA Signed: DataStax CLA

@Yuqi-Du Yuqi-Du requested a review from a team as a code owner October 16, 2025 17:24
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.

2 participants