How do I write the code in SQL?

{

“queryType”: “groupBy”,

“dataSource”: “test_datasource”,

“granularity”: “all”,

“dimensions”: [“user_id”],

“filter”: {

“type”: “or”,

“fields”: [

{“type”: “selector”, “dimension”: “product”, “value”: “A”}

]

},

“aggregations”: [

{

“type” : “filtered”,

“filter” : {

“type” : “and”,

“fields” : [

{

“type” : “selector”,

“dimension” : “product”,

“value” : “A”

},

{

“type” : “interval”,

“dimension” : “__time”,

“intervals” : [“2016-06-27T01:00:00.000Z/2016-06-27T03:00:00.000Z”]

}

]

},

“aggregator” : {

“type”: “thetaSketch”, “name”: “A_unique_users_week_1”, “fieldName”: “user_id_sketch”

}

},

{

“type” : “filtered”,

“filter” : {

“type” : “and”,

“fields” : [

{

“type” : “selector”,

“dimension” : “product”,

“value” : “A”

},

{

“type” : “interval”,

“dimension” : “__time”,

“intervals” : [“2016-06-27T03:00:00.000Z/2016-06-27T07:00:00.000Z”]

}

]

},

“aggregator” : {

“type”: “thetaSketch”, “name”: “A_unique_users_week_2”, “fieldName”: “user_id_sketch”

}

}

],

“postAggregations”: [

{

“type”: “thetaSketchEstimate”,

“name”: “final_unique_users”,

“field”:

{

“type”: “thetaSketchSetOp”,

“name”: “final_unique_users_sketch”,

“func”: “INTERSECT”,

“fields”: [

{

“type”: “fieldAccess”,

“fieldName”: “A_unique_users_week_1”

},

{

“type”: “fieldAccess”,

“fieldName”: “A_unique_users_week_2”

}

]

}

}

],

“intervals”: [“2016-06-27T00:00:00Z/2016-06-27T22:00:00Z”]

}

``

the data source is

{“id”:1,“timestamp”:“2016-06-27T01:00:11.080Z”,“product”:“A”,“user_id”:1}

{“id”:2,“timestamp”:“2016-06-27T02:00:34.959Z”,“product”:“B”,“user_id”:2}

{“id”:3,“timestamp”:“2016-06-27T03:00:36.027Z”,“product”:“A”,“user_id”:1}

{“id”:4,“timestamp”:“2016-06-27T04:00:58.599Z”,“product”:“B”,“user_id”:3}

{“id”:5,“timestamp”:“2016-06-27T05:01:03.685Z”,“product”:“B”,“user_id”:1}

{“id”:6,“timestamp”:“2016-06-27T06:01:07.347Z”,“product”:“A”,“user_id”:2}

``

the datasource metricsSpec

{ “type” : “thetaSketch”, “name” : “user_id_sketch”, “fieldName” : “user_id” }

``

I use thetaSketch, but i can’t find relevant documents.