Skip to main content
Question

How to query on json data ?

  • November 9, 2017
  • 3 replies
  • 20 views

ashu123
Forum|alt.badge.img+1

hello,
I was loaded json data into flex table

when i fetched days,it shows like this

how to in query on data array ??
ex: select maptostring(days=4) from testing_view ;

ERROR 4286: Operator does not exist: long varbinary = int
HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts

How to query on this please provide a solution
Thanks in advance

3 replies

ashu123
Forum|alt.badge.img+1
  • Author
  • Participating Frequently
  • November 10, 2017

plz provide solution i need that query :'( #Jim_Knicely


Jim_Knicely
Forum|alt.badge.img+2
  • Participating Frequently
  • November 10, 2017

Maybe the MAPITEMS function can help?

dbadmin=> select maptostring(days) from testing_view;
                                    maptostring
    ---------------------------------------------------------------------------
     {
       "0" : "3",
       "1" : "4",
       "2" : "5",
       "3" : "2",
       "4" : "3"
    }

     {
       "0" : "1",
       "1" : "2",
       "2" : "3",
       "3" : "1",
       "4" : "3"
    }

    (2 rows)

dbadmin=> select values from (select mapitems(days) over(partition best)from testing_view) foo where keys = 4;
 values
--------
 3
 3
(2 rows)

dbadmin=> select values from (select mapitems(days) over(partition best)from testing_view) foo where keys = 0;
 values
--------
 3
 1
(2 rows)

ashu123
Forum|alt.badge.img+1
  • Author
  • Participating Frequently
  • November 13, 2017

I got the solution o:)

select id from testing where mapcontainsvalue(__raw__['days'],'2')='t' ;

this will give u exact id's which 2 value contains