turbot / steampipe-plugin-turbot

Use SQL to instantly query the Turbot CMDB. Open source CLI. No DB required.

Home Page:https://hub.steampipe.io/plugins/turbot/turbot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`failed to populate column 'filter'` error when left joining `turbot_control` to `turbot_resource`

Joeturbot opened this issue · comments

Describe the bug
The filter column fails to populate with an unusual error.

Error: 2 connections failed: 
connection 'taurus': rpc error: code = Unknown desc = failed to populate column 'filter': FromQual transform can only be called if there is a singe equals qual for the given column
connection 'canis': rpc error: code = Unknown desc = failed to populate column 'filter': FromQual transform can only be called if there is a singe equals qual for the given column (SQLSTATE HV000)

Steampipe version

❯ steampipe --version
steampipe version 0.11.0

Plugin version (steampipe plugin list)
+--------------------------------------------------+---------+----------------------------------------------+
| Name | Version | Connections |
+--------------------------------------------------+---------+----------------------------------------------+
| hub.steampipe.io/plugins/turbot/aws@latest | 0.43.0 | aac,aaa,aws,aab,all_sandbox |
| hub.steampipe.io/plugins/turbot/azure@latest | 0.22.0 | azure |
| hub.steampipe.io/plugins/turbot/csv@latest | 0.1.0 | csv |
| hub.steampipe.io/plugins/turbot/gcp@latest | 0.19.0 | demo |
| hub.steampipe.io/plugins/turbot/github@latest | 0.10.0 | github |
| hub.steampipe.io/plugins/turbot/slack@latest | 0.3.0 | slack |
| hub.steampipe.io/plugins/turbot/steampipe@latest | 0.2.0 | steampipe |
| hub.steampipe.io/plugins/turbot/turbot@latest | 0.2.0 | corvus,taurus,astro,canis |
+--------------------------------------------------+---------+----------------------------------------------+

To reproduce

  1. Run this query against any single or multiple Turbot workspaces. I'm running TE 5.37.21.
with workspace as (
    select workspace
    from turbot_resource
    where filter = 'resourceId:"tmod:@turbot/turbot#/" level:self'
),
     webhook_rotation_policy as (
         select value,
                workspace,
                filter
         from turbot_policy_setting
         where filter = 'policyTypeId:"tmod:@turbot/turbot#/policy/types/webhookSecretRotation"'
     )
select w.workspace as resource,
       e.filter,
       case
           when e.value is null then 'Skip'
           else e.value
           end     as webhook_rotation_setting,
       case
           when e.value like 'Enforce: Rotate webhook secret' then 'ok'
           else 'alarm'
           end     as status,
       case
           when e.value like 'Enforce: Rotate webhook secret'
               then 'Webhook Secrets in ' || w.workspace || ' are set to rotate.'
           else 'Webhook Secrets in ' || w.workspace || ' do not rotate.'
           end     as status
from workspace w
         left join webhook_rotation_policy e using (workspace)
  1. I've tried running it against multiple workspace and against individual workspaces. There's no change in error.
  2. I've tried the webhook_rotation_policy query alone and it works just fine. The workspace query returns properly too. My hunch is that filter error comes from joining the two queries.

Expected behavior
I get a list of workspaces with a column indicating whether the Webhook rotation policy has been set to Enforce or not.

Additional context
Working on a Turbot Workspace health mod. This query is a part of that effort.

This reproduces the error for me.

with workspace as (
  select 
    workspace
  from 
    turbot_resource
  where 
    filter = 'resourceId:"tmod:@turbot/turbot#/" level:self'
),

rotation_policy as (
  select 
    workspace,
    value,
    filter
  from 
    turbot_policy_setting
  where 
    filter = 'policyTypeId:"tmod:@turbot/turbot#/policy/types/webhookSecretRotation"'
  ),

joined as (
  select
    *
from
  workspace
left join
  rotation_policy
using
  (workspace)
)

select  * from joined

Adding an order by to the rotation_policy CTE resolves it.

One more reference for turbot/steampipe#968, probaby.

Thanks @judell I never would have thought to use order by. I'll give it a try.

Yep, use of order by solves the problem. Query works as expected now.

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.