Jira (PDB-5226) Dotted fact path group by doesn't group

16 views
Skip to first unread message

Austin Blatt (Jira)

unread,
Aug 2, 2021, 7:36:02 PM8/2/21
to puppe...@googlegroups.com
Austin Blatt created an issue
 
PuppetDB / Bug PDB-5226
Dotted fact path group by doesn't group
Issue Type: Bug Bug
Affects Versions: PDB 6.18.1
Assignee: Unassigned
Created: 2021/08/02 4:35 PM
Fix Versions: PDB 6.18.2
Priority: Normal Normal
Reporter: Austin Blatt
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Austin Blatt (Jira)

unread,
Aug 2, 2021, 7:41:04 PM8/2/21
to puppe...@googlegroups.com
Austin Blatt updated an issue
Change By: Austin Blatt
{code}
curl -X POST http://localhost:8080/pdb/query/v4 2>/dev/null \
  -H 'Content-Type:application/json' \
  -d '{"query": "inventory[facts.osfamily, count()]{ group by facts.osfamily }" }'
{code}

Produces the SQL
{code}
2021-08-02 16:36:18,728 INFO  [qtp90455758-58] [p.p.query-eng] PDBQuery:b1e56636-dc83-45c4-8943-90620ec4d2d1:["WITH inactive_nodes AS (SELECT certname FROM certnames WHERE (deactivated IS NOT NULL AND deactivated > '2021-07-19T23:36:18.728Z') OR (expired IS NOT NULL and expired > '2021-07-19T23:36:18.728Z')), not_active_nodes AS (SELECT certname FROM certnames WHERE (deactivated IS NOT NULL OR expired IS NOT NULL)) SELECT (fs.stable||fs.volatile)->'osfamily' AS \"facts.osfamily\", count(*) count FROM factsets fs LEFT JOIN environments ON fs.environment_id = environments.id LEFT JOIN certnames ON fs.certname = certnames.certname WHERE NOT ((certnames.certname) in (SELECT certname FROM  ( SELECT not_active_nodes.certname AS \"certname\" FROM not_active_nodes )  sub)) GROUP BY (fs.stable||fs.volatile)"]
{code}

but the {{GROUP BY}} filter is wrong. Instead of the `:field` value of the requested {{facts.osfamily}}, it should be the projection name, surrounded by double quotes.

The correct SQL would look like
{code}
WITH inactive_nodes AS (SELECT certname FROM certnames WHERE (deactivated IS NOT NULL AND deactivated > '2021-07-19T23:36:18.728Z') OR (expired IS NOT NULL and expired > '2021-07-19T23:36:18.728Z')), not_active_nodes AS (SELECT certname FROM certnames WHERE (deactivated IS NOT NULL OR expired IS NOT NULL)) SELECT (fs.stable||fs.volatile)->'osfamily' AS "facts.osfamily", count(*) count FROM factsets fs LEFT JOIN environments ON fs.environment_id = environments.id LEFT JOIN certnames ON fs.certname = certnames.certname WHERE NOT ((certnames.certname) in (SELECT certname FROM  ( SELECT not_active_nodes.certname AS "certname" FROM not_active_nodes )  sub)) GROUP BY "facts.osfamily";
{code}

Austin Blatt (Jira)

unread,
Aug 2, 2021, 7:57:01 PM8/2/21
to puppe...@googlegroups.com
Austin Blatt updated an issue
Change By: Austin Blatt
Sprint: HA 2021-08-11

Austin Blatt (Jira)

unread,
Aug 2, 2021, 7:57:04 PM8/2/21
to puppe...@googlegroups.com
Austin Blatt assigned an issue to Austin Blatt
Change By: Austin Blatt
Assignee: Austin Blatt

Austin Blatt (Jira)

unread,
Aug 2, 2021, 7:57:04 PM8/2/21
to puppe...@googlegroups.com

Dave Woods (Jira)

unread,
Aug 4, 2021, 5:32:02 AM8/4/21
to puppe...@googlegroups.com
Dave Woods commented on Bug PDB-5226
 
Re: Dotted fact path group by doesn't group

Austin Blatt where can we get our hands on a server with this fix?  Lynsay Wright has made a fix in the ER Query Service and needs to verify it against the latest fix, before we cut a new release and hand it over to Chris Leicester for a CD4PE release.

Austin Blatt (Jira)

unread,
Aug 19, 2021, 1:56:03 PM8/19/21
to puppe...@googlegroups.com
Austin Blatt updated an issue
Change By: Austin Blatt
Fix Version/s: PDB 7.5.2

Joshua Partlow (Jira)

unread,
Feb 10, 2023, 2:49:05 PM2/10/23
to puppe...@googlegroups.com
Joshua Partlow updated an issue
Change By: Joshua Partlow
Affects Version/s: PDB 6.18.1
Affects Version/s: PDB 6.18.0
This message was sent by Atlassian Jira (v8.20.11#820011-sha1:0629dd8)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages