Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][Spark] Changing type of map/array field referenced by a generated column or CHECK constraint not failing correctly #3634

Open
1 of 3 tasks
johanl-db opened this issue Sep 3, 2024 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@johanl-db
Copy link
Collaborator

Bug

Describe the problem

See #3601 (comment)

Changing the data type of a field that is referenced by a generated column or CHECK constraint is forbidden as this may change the result returned by that expression.

This is checked in AlterDeltaTableCommands for manual type changes and ImplicitMetadataOperation for type changes applied during schema evolution. These checks don't work correctly for fields nested inside a map or array.

This is because generated column and CHECK constraint expression use paths that referenced a specific element in the array or map, e.g. col.arr[0] whereas the path that the check looks for is a generic schema path to that element: col.element

Steps to reproduce

Create a table with schema a struct<arr: array<struct<x: smallint>>> and insert an int value for field x.

See similar test:

test("disallow column type evolution - nesting") {

Observed results

The write succeeds

Expected results

The operation should fail

Willingness to contribute

The Delta Lake Community encourages bug fix contributions. Would you or another member of your organization be willing to contribute a fix for this bug to the Delta Lake code base?

  • Yes. I can contribute a fix for this bug independently.
  • Yes. I would be willing to contribute a fix for this bug with guidance from the Delta Lake community.
  • No. I cannot contribute a bug fix at this time.
@johanl-db johanl-db added the bug Something isn't working label Sep 3, 2024
@johanl-db johanl-db changed the title [BUG][Spark] Changing type of map/array field referenced by a generated column or CHECK constraint not failing [BUG][Spark] Changing type of map/array field referenced by a generated column or CHECK constraint not failing correctly Sep 3, 2024
@johanl-db johanl-db added the good first issue Good for newcomers label Sep 3, 2024
@xzhseh
Copy link
Contributor

xzhseh commented Sep 3, 2024

Hi @johanl-db, I can take this one and investigate further to see if we can find a graceful solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants