Join with empty data


I have a problem with the join functions. If the left or right table is empty, I get an error table is missing label {labelName}. Is there any option to check if the table is empty or not? I have found a solution on the Internet and created this workaround, but it is a pain to check if the table exists or not. I think the join function should deal with these empty tables.

isEmpty = (tables) => {
	columnsArray = tables
		|> columns()
		|> findColumn(fn: (key) => true, column: "_value")
	return length(arr: columnsArray) == 0

locations = from(bucket: {bucket})... //omitted for brevity
pallet = from(bucket: {bucket})...  //omitted for brevity

isLeftEmpty = isEmpty(tables: locations)
isRightEmpty = isEmpty(tables: pallet)

leftDummy = array.from(rows: [{SensorId: "-1", Moving: 0}])
rightDummy = array.from(rows: [{SensorId: "-1", Pallet: 0}])

	method: "left",
	left:  if isLeftEmpty then leftDummy else locations,
	right: if isRightEmpty then rightDummy else pallet,
	on: (l, r) => l.SensorId == r.SensorId,
	as: (l, r) => {
		return {l with Pallet: r.Pallet}