Skip to content

Conversation

@plcplc
Copy link
Contributor

@plcplc plcplc commented Apr 5, 2024

What

This PR adds support for selecting nested fields that arise from composite arrays.

How

This builds on the earlier work for nested field selection support for objects.

The main change is that the lateral joins that project the nested field have to be nested rather than adjacent as well, since there are multiple rows in the case of arrays.

The generated SQL is now of the form:

LEFT OUTER JOIN LATERAL (
  SELECT
    <collect_expression> AS "collected"
  FROM
    (
      < select of translate_fields(fields, nested_field_binding_alias, ... )
        which includes joins from recursive calls>
       FROM
         (
            SELECT
             (<field_binding_expression>).*
         ) AS <nested_field_binding> ON ('true')
     ) AS <nested_fields>
) AS <nested_fields_collect> ON ('true')

@plcplc plcplc enabled auto-merge April 5, 2024 18:30
@plcplc plcplc changed the title Support nested fields of object type Support nested fields of array type Apr 5, 2024
Copy link
Contributor

Choose a reason for hiding this comment

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

bak?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, this was staged by accident. I have removed it.

@plcplc plcplc requested a review from soupi April 8, 2024 11:17
plcplc and others added 3 commits April 8, 2024 15:26
Co-authored-by: Daniel Harvey <danieljamesharvey@gmail.com>
Co-authored-by: Daniel Harvey <danieljamesharvey@gmail.com>
Co-authored-by: Daniel Harvey <danieljamesharvey@gmail.com>
Copy link
Contributor

@danieljharvey danieljharvey left a comment

Choose a reason for hiding this comment

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

Thank you for going into such detail with the comments and the examples.

@plcplc plcplc added this pull request to the merge queue Apr 8, 2024
Merged via the queue into main with commit 87c2ef3 Apr 8, 2024
@plcplc plcplc deleted the plc/issues/PG-73-arrays branch April 8, 2024 13:36
@soupi
Copy link
Contributor

soupi commented Apr 8, 2024

indeed, this is very nice!

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