Jira (PDB-4493) Query function count() broken for JSON fields

0 views
Skip to first unread message

Austin Blatt (JIRA)

unread,
Sep 5, 2019, 5:44:03 PM9/5/19
to puppe...@googlegroups.com
Austin Blatt created an issue
 
PuppetDB / Bug PDB-4493
Query function count() broken for JSON fields
Issue Type: Bug Bug
Affects Versions: PDB 6.5.0, PDB 6.3.4, PDB 5.2.9
Assignee: Unassigned
Created: 2019/09/05 2:43 PM
Priority: Normal Normal
Reporter: Austin Blatt

For a query like

facts[name, count(value)] {
  certname ~ "^pe.*"
  group by name
}

The query engine currently constructs an SQL SELECT that looks like

SELECT    fs.key                         AS name,
          count((value#>>'{}')::numeric)    count

Which causes the error

javax.servlet.ServletException: org.postgresql.util.PSQLException: ERROR: invalid input syntax for type numeric: "root"

But the argument to count is invalid and it should be closer to

SELECT    fs.key                         AS name,
          count(value)    count

NOTE: The error will only happen if the table has data.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Austin Blatt (JIRA)

unread,
Sep 5, 2019, 5:47:03 PM9/5/19
to puppe...@googlegroups.com
Austin Blatt updated an issue
Change By: Austin Blatt
For a query like
{code}

facts[name, count(value)] {
  certname ~ "^pe.*"
  group by name
}
{code}

The query engine currently constructs an SQL SELECT that looks like
{code}
SELECT    fs.key                     AS name,
          count((value#>>'{}')::numeric)    count
{code}

Which causes the error

{code}
javax.servlet.ServletException: org.postgresql.util.PSQLException: ERROR: invalid input syntax for type numeric: "root"
{code}

But the
The argument to count is invalid and it should be closer to
{code}

SELECT    fs.key                     AS name,
          count(value)    count
{code}


*_NOTE_: The error will only happen if the table has data.*
Reply all
Reply to author
Forward
0 new messages