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

sql: support correlated subquery in DELETE WHERE clause #31670

Closed
knz opened this issue Oct 20, 2018 · 6 comments
Closed

sql: support correlated subquery in DELETE WHERE clause #31670

knz opened this issue Oct 20, 2018 · 6 comments
Labels
A-sql-optimizer SQL logical planning and optimizations. A-sql-pgcompat Semantic compatibility with PostgreSQL A-testing Testing tools and infrastructure A-tools-hibernate Issues that pertain to Hibernate integration. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
Milestone

Comments

@knz
Copy link
Contributor

knz commented Oct 20, 2018

Is your feature request related to a problem? Please describe.

Found via the Hibernate test org.hibernate.test.hql.BulkManipulationTest.testDeleteWithSubquery

        delete
        from
            MANY_TO_MANY
        where
            (
                IN_ID
            ) in (
                select
                    ID
                from
                    SIMPLE_1
                where
                    (
                        select
                            count(associated1_.SIMPLE_1_ID)
                        from
                            SIMPLE_2 associated1_
                        where
                            SIMPLE_1.ID=associated1_.SIMPLE_1_ID
                    )=0
                    and (
                        NAME like '%'
                    )
                )
@knz knz added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-optimizer SQL logical planning and optimizations. A-testing Testing tools and infrastructure A-tools-hibernate Issues that pertain to Hibernate integration. labels Oct 20, 2018
@knz knz added this to the 2.2 milestone Oct 20, 2018
@knz
Copy link
Contributor Author

knz commented Oct 20, 2018

Another via org.hibernate.test.hql.DeleteWithSubqueryTest.testDeleteMemberOf

        delete
        from
            Attrvalue
        where
            id in (
                select
                    attrvalue4_.id
                from
                    Employee employee1_ cross
                join
                    Employeegroup employeegr2_ cross
                join
                    Attrset attrset3_ cross
                join
                    Attrvalue attrvalue4_
                where
                    employeegr2_.id=employee1_.employeegroup_id
                    and attrset3_.id=employee1_.attrset_id
                    and (
                        attrvalue4_.id in (
                            select
                                attrvalues5_.attrvalues_id
                            from
                                ATTRSET_X_ATTRVALUE attrvalues5_
                            where
                                attrset3_.id=attrvalues5_.Attrset_id
                        )
                    )
                )

@awoods187
Copy link
Contributor

@andy-kimball would this work once mutations are supported in 2.2? Would this need the apply operator @jordanlewis ?

@knz
Copy link
Contributor Author

knz commented Oct 22, 2018

Yes optimizer knowledge of mutation will be 70% of the work needed here. For the requirement on apply, it will depend on the query I think. Not sure about those quoted above.

@andy-kimball
Copy link
Contributor

Yes, I'd expect these to work once we added CRUD support to the optimizer. They shouldn't need Apply.

@BramGruneir
Copy link
Member

Closed thanks to #33524.

BramGruneir added a commit to BramGruneir/cockroach that referenced this issue Feb 4, 2019
Thanks to #cockroachdb#33524, cockroachdb#31670 is now closed, so 3 more tests are passing.

Release note: None
craig bot pushed a commit that referenced this issue Feb 4, 2019
34541: roachtest: update hibernate blacklist r=BramGruneir a=BramGruneir

Thanks to ##33524, #31670 is now closed, so 3 more tests are passing.

Release note: None

Co-authored-by: Bram Gruneir <bram@cockroachlabs.com>
@BramGruneir
Copy link
Member

BramGruneir commented Feb 4, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-optimizer SQL logical planning and optimizations. A-sql-pgcompat Semantic compatibility with PostgreSQL A-testing Testing tools and infrastructure A-tools-hibernate Issues that pertain to Hibernate integration. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
Projects
None yet
Development

No branches or pull requests

4 participants