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

Left JOIN pushdown problem? #173

Open
ugurlu opened this issue Dec 15, 2023 · 3 comments
Open

Left JOIN pushdown problem? #173

ugurlu opened this issue Dec 15, 2023 · 3 comments

Comments

@ugurlu
Copy link

ugurlu commented Dec 15, 2023

Hello,

When default options are used LEFT JOIN returns no results. If the enable_join_pushdown is set to false, query works as expected. Tried on 5.1.1

@vaibhavdalvi93
Copy link

Thanks, @ugurlu for reporting an issue. Could you please provide us the problematic query along with table definitions to look into it further?

@ugurlu
Copy link
Author

ugurlu commented Dec 18, 2023

Thank you for the quick response

Following query returns empty set.

select t.* from testlog t
	left join testdevice d on d.mac = t."logMeta.logMac";
CREATE FOREIGN table testdevice
	(
		_id int,
		"name" varchar,
		"mac" varchar
	)
	SERVER mongo_server
	OPTIONS (database 'testdb', collection 'testdevice');
CREATE FOREIGN table testlog
	(
		_id int,
		"log" varchar,
		"logMeta.logMac" varchar
	)
	SERVER mongo_server
	OPTIONS (database 'testdb', collection 'testlog');
{
  "_id": {
    "$oid": "658040214898199d6e0173d0"
  },
  "log": "hello log",
  "logMeta": {
    "logMac": "001122334455"
  }
}
{
  "_id": {
    "$oid": "6580400c4898199d6e0173cd"
  },
  "mac": "001122334455",
  "name": "test device"
}

@vaibhavdalvi93
Copy link

Thank you, @ugurlu for detailed information. I can confirm this as a bug with join pushdown. I could reproduce this issue on mongo_fdw latest version i.e. 5.5.1. I have reported this issue internally and we will try to fix this issue in near future. On high level I suspect that Join push-down not returning a result for join condition on sub-column because MongoDB query pipeline is getting incorrectly formed.

jeevanchalke added a commit that referenced this issue Dec 20, 2024
The variable name we use to declare the column of outer relation
using the $let field is the same as the column name.  However, if
the column is a sub-column (i.e., "parent.child"), then the variable
name also contains the dot ("."), which is not allowed in variable
name formation, resulting in a wrong resultset being returned from
the server.

Since special characters other than underscore ("_") are not allowed,
let's use underscore instead of dot to fix the issue.

Reported on GitHub through issue #173 by Ömer Sezgin Uğurlu (ugurlu).

FDW-669, Vaibhav Dalvi, reviewed by Sravan Velagandula,
tested by Kashif Zeeshan.
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