Skip to content

[BUG] query rewriting error using JSON_EXTRACT #352

Closed

Description

@datwiz

Describe the bug
Using JSON_EXTRACT(...) with json field from a sub-query returns an error.

Example query:

select
    JSON_EXTRACT(<json_col>, '$.<json_field>') as extracted_field
from
(
    select
        <json_row>.value as <json_col>
    from <provider>.<service>.<resource> as <alias>
        , json_each(<json_array_field>) AS <json_row>
) raw

Returns

query rewriting for indirection:: cannot file col = 'JSON_EXTRACT(<json_col>, '$.<json_field>')'

To Reproduce
Example using the pagerduty resource provider.

select
    JSON_EXTRACT(contact_method, '$.html_url') as contact_method_html_url
from
(
    select
        contact_method.value as contact_method
    from pagerduty.users.users as pdu
        , json_each(contact_methods) AS contact_method
) raw

Returns

stackql exec -i sub-query-cols.iql
query rewriting for indirection: cannot find col = 'JSON_EXTRACT(contact_method, '$.html_url')'

Desktop (please complete the following information):

  • OS: macOS
  • SatckQL Version: v0.5.509 (57dbab7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions