Flux join.full() operation not working properly?

I am using the latest Influx Cloud build and I want to do a full outer join on 2 queries, but i get a runtime error…

import "join"

good = from(bucket: "cp")
  |> range(start: 2020-01-01T01:00:00Z)
  |> filter(fn: (r) => r["_measurement"] == "cycle" and r["_field"] == "result" and r["_value"] == true)
  |> group(columns: ["tag1", "tag2", "tag3", "tag4", "tag5"])
	|> rename(columns: { _value: "good"})
	|> keep(columns: ["tag1", "tag2", "tag3", "tag4", "good", "tag5"])
  |> count(column: "good")
	
bad = from(bucket: "cp")
  |> range(start: 2020-01-01T01:00:00Z)
  |> filter(fn: (r) => r["_measurement"] == "cycle" and r["_field"] == "result" and r["_value"] == false)
  |> group(columns: ["tag1", "tag2", "tag3", "tag4", "tag5"])
	|> rename(columns: { _value: "bads"})
	|> keep(columns: ["tag1", "tag2", "tag3", "tag4", "bad", "tag5"])
  |> count(column: "bad")
	
	join.full(left: good, right: bad,
    on: (l, r) => l.tag1 == r.tag1 and l.tag2 == r.tag2 and l.tag3 == r.tag3 and l.tag4 == r.tag4 and l.tag5 == r.tag5,
    as: (l, r) => {
				tag1 = if exists l.tag1 then l.tag1 else r.tag1
				tag2 = if exists l.tag2 then l.tag2 else r.tag2
				tag3 = if exists l.tag3 then l.tag3 else r.tag3
				tag4 = if exists l.tag4 then l.tag4 else r.tag4
				tag5 = if exists l.tag5 then l.tag5 else r.tag5

        return {tag1: tag1, tag2: tag2, tag3: tag3, tag4: tag4, tag5: tag5, good: l.good, bad: r.bad}
    })

With this query I got the following error message:

500 Internal Server Error
{
	"code": "internal error",
	"message": "runtime error @21:2-31:7: full: invalid message"
}

If I use generated data with arrays as in the example the previous join works perfectly.

import "join"
import "array"
	
	left = array.from(rows: [
		{tag1: "t111", tag2: "t111", tag3: "t111", tag4: "t111", tag5: "t111", good: 10},
		{tag1: "t111", tag2: "t222", tag3: "t111", tag4: "t111", tag5: "t111", good: 11},
		{tag1: "t111", tag2: "t111", tag3: "t333", tag4: "t111", tag5: "t111", good: 12},
		{tag1: "t111", tag2: "t111", tag3: "t111", tag4: "t111", tag5: "t111", good: 13},
		{tag1: "t111", tag2: "t111", tag3: "t111", tag4: "t444", tag5: "t111", good: 14},
	])		
	
	right = array.from(rows: [
		{tag1: "t111", tag2: "t111", tag3: "t111", tag4: "t111", tag5: "t111", bad: 10},
		{tag1: "t111", tag2: "t222", tag3: "t111", tag4: "t111", tag5: "t111", bad: 11},
		{tag1: "t111", tag2: "t111", tag3: "t111", tag4: "t111", tag5: "t555", bad: 12},
		{tag1: "t111", tag2: "t333", tag3: "t111", tag4: "t111", tag5: "t111", bad: 13},
		{tag1: "t666", tag2: "t111", tag3: "t111", tag4: "t111", tag5: "t111", bad: 14},
	])
	
	join.full(left: left, right: right,
    on: (l, r) => l.tag1 == r.tag1 and l.tag2 == r.tag2 and l.tag3 == r.tag3 and l.tag4 == r.tag4 and l.tag5 == r.tag5,
    as: (l, r) => {
				tag1 = if exists l.tag1 then l.tag1 else r.tag1
				tag2 = if exists l.tag2 then l.tag2 else r.tag2
				tag3 = if exists l.tag3 then l.tag3 else r.tag3
				tag4 = if exists l.tag4 then l.tag4 else r.tag4
				tag5 = if exists l.tag5 then l.tag5 else r.tag5

        return {tag1: tag1, tag2: tag2, tag3: tag3, tag4: tag4, tag5: tag5, good: l.good, bad: r.bad}
    })

Returns this table as a result:

But if i run just my good (or bad) query it returns a table as well.

good = from(bucket: "cp")
  |> range(start: 2020-01-01T01:00:00Z)
  |> filter(fn: (r) => r["_measurement"] == "cycle" and r["_field"] == "result" and r["_value"] == true)
  |> group(columns: ["tag1", "tag2", "tag3", "tag4", "tag5"])
	|> rename(columns: { _value: "good"})
	|> keep(columns: ["tag1", "tag2", "tag3", "tag4", "good", "tag5"])
  |> count(column: "good")

My queries (good and bad) working perfectly individually, but I can’t join them. My join is working perfectly individually as well with the generated data.

I noticed that in the generated data the default “table” column only contains 0 values and in my queries it is an ascending number (0 - 12). This is the only difference I can find between the 2.

The same problem is happening when I try to use the join.left(), join.right() and join.tables() functions as well.
The only one is working with my queries is the simple join() function but this is an inner join and I need a full outer join.

Can you help me with this problem please?

Thank you in advance!

Hello @gomorib,
Using joins is confusing for me too.
I get this to work:

import outer "join" 
import "internal/debug"
import "array"
	
	left = array.from(rows: [
		{tag1: "t111", tag2: "t111", tag3: "t111", tag4: "t111", tag5: "t111", good: 10, _time: 1, _value: 1},
		{tag1: "t111", tag2: "t222", tag3: "t111", tag4: "t111", tag5: "t111", good: 11, _time: 2, _value: 1},
		{tag1: "t111", tag2: "t111", tag3: "t333", tag4: "t111", tag5: "t111", good: 12, _time: 3, _value: 1},
		{tag1: "t111", tag2: "t111", tag3: "t111", tag4: "t111", tag5: "t111", good: 13, _time: 4, _value: 1},
		{tag1: "t111", tag2: "t111", tag3: "t111", tag4: "t444", tag5: "t111", good: 14, _time: 5, _value: 1},
	])		
	
	right = array.from(rows: [
		{tag1: "t111", tag2: "t111", tag3: "t111", tag4: "t111", tag5: "t111", bad: 10, _time: 1, _value: 1},
		{tag1: "t111", tag2: "t222", tag3: "t111", tag4: "t111", tag5: "t111", bad: 11, _time: 2, _value: 1},
		{tag1: "t111", tag2: "t111", tag3: "t111", tag4: "t111", tag5: "t555", bad: 12, _time: 3, _value: 1},
		{tag1: "t111", tag2: "t333", tag3: "t111", tag4: "t111", tag5: "t111", bad: 13, _time: 4, _value: 1},
		{tag1: "t666", tag2: "t111", tag3: "t111", tag4: "t111", tag5: "t111", bad: 14, _time: 5, _value: 1},
	])
outer.time(left: left, right: right, as: (l, r) => ({l with label: r._value}), method: "full" )

// or sometimes you might have luck using debug.pass to silence messages like so, also worth giving a try. If this works with your query can you let me know so that I can create an issue? That would be amazing. 
// outer.time(left: left |> debug.pass(), right: right |> debug.pass(), as: (l, r) => ({l with label: r._value}), method: "full" )

I find using join.time() a little easier.

Flux team got a few reports of similar issues. This should be resolved as of the 0.176.0 release.

1 Like

I hate to say this, but starting from yesterday morning it started working properly without any issues with the exact same query, I did not modify anything. Maybe it was a server issue.

Thank you for your tip to use outer.time(), it could be a solution in this cases, but i do not have time in my “good” and “bad” queries because I use grouping and count().

Anyway, thank you for your help! :slight_smile:

1 Like

I’m glad it’s working now!