Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to create query with dataSource as type query #78

Open
saketbairoliya2 opened this issue Nov 16, 2022 · 1 comment
Open

Not able to create query with dataSource as type query #78

saketbairoliya2 opened this issue Nov 16, 2022 · 1 comment

Comments

@saketbairoliya2
Copy link
Contributor

I'm trying to run following query:

{
	"queryType": "timeseries",
	"dataSource": {
		"type": "query",
		"query": {
			"aggregations": [
				{
					"fieldName": "count",
					"name": "count",
					"type": "longSum"
				}
			],
			"dataSource": {
				"name": "dc_94b4f5fdfde940979b79c50539d8322a_b42fde98efed4e638a0016b34b3c10cf_dataset_pre",
				"type": "table"
			},
			"dimension": {
				"dimension": "string_value",
				"type": "default"
			},
			"filter": {
				"fields": [
					{
						"dimension": "_split_name__",
						"type": "selector",
						"value": "train"
					},
					{
						"dimension": "column_name",
						"type": "selector",
						"value": "addressState"
					}
				],
				"type": "and"
			},
			"granularity": "day",
			"intervals": {
				"intervals": [
					"${__from:date:iso}/${__to:date:iso}"
				],
				"type": "intervals"
			},
			"metric": {
				"metric": "count",
				"type": "numeric"
			},
			"queryType": "topN",
			"threshold": 100
		}
	},
	"intervals": {
		"type": "intervals",
		"intervals": [
			"${__from:date:iso}/${__to:date:iso}"
		]
	},
	"granularity": "day"
}

Screenshot 2022-11-16 at 5 02 12 PM

Getting error for query to be null - Looks like we're always returning null here: https://github.com/grafadruid/go-druid/blob/master/builder/datasource/query.go#L24

@bourbonkk
Copy link
Contributor

@saketbairoliya2
I fixed this bug in #82 PR

There were code modifications.
Query struct : "-,omitempty" -> "query,omitempty"

type Query struct {
	Base
	Query builder.Query `json:"query,omitempty"`
}

This is necessary to make a subquery.

And I wrote the test code for the subquery, so please check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants