ekuiper icon indicating copy to clipboard operation
ekuiper copied to clipboard

In Graph API, how to transform the outcome from a windowing function to non-grouped value

Open revozhang opened this issue 2 years ago • 8 comments

I have the following graph

{
	node1: {
		type: 'operator',
		nodeType: 'window',
		props: {
			type: 'tumblingwindow',
			unit: 'ss',
			size: 10,
		},
	},
}, {
	node2: {
		type: 'operator',
		nodeType: 'aggfunc',
		props: {
			expr: 'avg(value)',
		},
	},
}, {
	node3: {
		type: 'operator',
		nodeType: 'function',
		props: {
			expr: 'abs(avg)',
		},
	},
},

but got error message saying:

collection type mismatch, expect non-grouped collection, got grouped collection

Can I use a pick operator to select the first element of the collection? Thanks.

revozhang avatar Feb 08 '23 17:02 revozhang

Update I replaced node3 with a script node trying to process the avg value:

node3: {
                type: 'operator',
                nodeType: 'script',
                props: {
                  script:
                    'function exec(msg, meta) { return msg.avg}',
                  isAgg: true,
                },
              }

Now the error message says:

input type mismatch, expect row, got collection

revozhang avatar Feb 08 '23 19:02 revozhang

Hi, @ngjaying thank you for looking into this. Do you have a solution for this now or is it coming? I was trying to implement my own function plugin to covert the collection into a row, but it seems to be a circle. In order to consume the data from the window function, my function needs to declare IsAggregate() true. Thus my function becomes one that outputs collection again. Is there a way to get around this dilemma? Thanks!

revozhang avatar Feb 21 '23 19:02 revozhang

Sorry, I don't have time to look into this deeply. I don't think we have the mechanism to convert collection back into one row now.

ngjaying avatar Feb 23 '23 02:02 ngjaying

OK. Do you have any tips how I should go ahead and implement it? As mentioned above, if I declare IsAggregate true for my function, does it mean my function only accept collection and only output collection too? Thanks!

revozhang avatar Feb 23 '23 03:02 revozhang

OK. Do you have any tips how I should go ahead and implement it? As mentioned above, if I declare IsAggregate true for my function, does it mean my function only accept collection and only output collection too? Thanks!

Yes, this is the current design

ngjaying avatar Feb 23 '23 04:02 ngjaying

Hello, thank you for this amazing project. I was wondering if there is any update about this topic.

Thanks

ghezzis avatar Jun 28 '23 07:06 ghezzis

There is no update on this issue. Welcome to share your ideas here.

ngjaying avatar Jun 28 '23 07:06 ngjaying

This should be supported after implementing #2504

ngjaying avatar Dec 27 '23 04:12 ngjaying