-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
unsupported comparison operator: <oid> NOT IN <tuple{int}> #14554
Comments
@tlvenn, could you please provide the full query that's being issued by Postgrex here? I've looked at the code that generates it, but I'm afraid I'm not fluent enough in Elixir to be able to construct the query by staring at the code. |
The underlying issue here is the following query:
The reason it fails to type properly is that our type system currently does not correctly propagate desired types into subqueries. If that was done correctly, the query would type properly, as the type system knows that Fixing this issue can be done (at least) two ways:
As an alternative, I've opened elixir-ecto/postgrex#310 since it appears that this subquery is not necessary and can be replaced by a list of integer literals. |
For the record, the full query getting executed by Postgrex is:
|
Hi @jordanlewis, sorry was pretty busy the past 2 days and I am only now catching up with emails, github notifications and the like. Unfortunately, we can't use yet the default Postgrex driver because the following query still dont run in CDB:
So I am still maintaining a fork at https://github.com/jumpn/postgrex that is getting rid of that For now I am doing an explicit cast to int as a workaround. |
Indeed, I didn't notice because of the other issues above, but this query uses a correlated subquery which we don't support yet - see #3288. |
Ha thanks for the pointer @jordanlewis, looks like I will have to maintain my fork for a little bit longer ;) |
Unfortunately it looks that way, yes. Thank you for sticking with it - really appreciate your persistence on this issue! 😊 |
The java SQL library jOOQ also needs this feature according to this tweet |
The query in question that jOOQ generates is as follows:
|
DataNucleus uses a table validation strategy during table creation/generation which also uses this comparison. Full query:
Using version CockroachDB v1.1-alpha.20170817 |
@jordanlewis could you have a look at the last query pasted above from @Fathardie? It seems to me that this is a simpler case for which you already have done some thinking (namely, ensure that an OID placeholder delivered by the client as int during execute is treated as OID during the 2nd type checking). |
If this is indeed a separate case, please fork that sub-discussion into a separate issue (or reuse existing issue if there's one) |
Hi @jordanlewis, Now that CDB with the latest v19 version is handling correlated subqueries , I though I would test what is happening now with Postgrex, given it should pretty much work or so I hoped ;)
Wasn't this supposed to be fixed with #16672 ? Any idea why I am still running into this ? For info, this is with:
|
Hey @tlvenn, glad you're waiting with bated breath, haha - and hmm yeah I would have expected this to not come up anymore. Could you send me server logs generated with |
here you go:
|
Sigh, looks like this didn't really get closed by the linked issue. That was about making sure placeholders got typed correctly in similar circumstances. We still don't support mixed type comparisons of this nature. I'll see about making this happen sooner rather than later. |
Thanks @jordanlewis that would be awesome, i believe this is the final bit to be able to use Elixir Postgresql driver without any fork whatsoever. |
Hey @tlvenn, as much as I don't like to admit it, fixing this isn't easy. The change to the query, on the other hand, is very easy and will be compatible in both PG and CRDB. Would you consider it? All you would have to do is add a single |
The latest version of CockroachDB comes with full support for correlated subqueries which was an issue before. Now the only stoper is one sql fragment where an explicity cast is currently needed. See: cockroachdb/cockroach#14554
Crossing fingers ;) |
The latest version of CockroachDB comes with full support for correlated subqueries which was an issue before. Now the only stoper is one sql fragment where an explicity cast is currently needed. See: cockroachdb/cockroach#14554
Change has been merged on Postgrex side so all is good now as far as Elixir is concerned 🎉 @dianasaur323 you might want to update the labels as I believe this should be classified as a bug or an enhancement. |
@tlvenn this is awesome! So happy to hear it - it's been a bit of a saga. As a small thank you for sticking with us, if you want, email me at jordan@cockroachlabs.com with your tshirt size and mailing address and we'll send you a small gift :) |
Thanks will do ! Btw did you mean to close the issue ? |
Heh, nope. |
Prior to this commit, the optimizer was not correctly inferring the types of columns in subqueries for expressions of the form `scalar IN (subquery)`. This was due to two problems which have now been fixed: 1. The subquery was built as a relational expression before the desired types were known. Now the subquery build is delayed until TypeCheck is called for the first time. 2. For subqueries on the right side of an IN expression, the desired type passed into TypeCheck was AnyTuple. This resulted in an error later on in typeCheckSubqueryWithIn, which checks to make sure the type of the subquery is tuple{T} where T is the type of the left expression. Now the desired type passed into TypeCheck is tuple{T}. Note that this commit only fixes type inference for the optimizer. It is still broken in the heuristic planner. Fixes cockroachdb#37263 Fixes cockroachdb#14554 Release note (bug fix): Fixed type inference of columns in subqueries for some expressions of the form `scalar IN (subquery)`.
Prior to this commit, the optimizer was not correctly inferring the types of columns in subqueries for expressions of the form `scalar IN (subquery)`. This was due to two problems which have now been fixed: 1. The subquery was built as a relational expression before the desired types were known. Now the subquery build is delayed until TypeCheck is called for the first time. 2. For subqueries on the right side of an IN expression, the desired type passed into TypeCheck was AnyTuple. This resulted in an error later on in typeCheckSubqueryWithIn, which checks to make sure the type of the subquery is tuple{T} where T is the type of the left expression. Now the desired type passed into TypeCheck is tuple{T}. Note that this commit only fixes type inference for the optimizer. It is still broken in the heuristic planner. Fixes cockroachdb#37263 Fixes cockroachdb#14554 Release note (bug fix): Fixed type inference of columns in subqueries for some expressions of the form `scalar IN (subquery)`.
37506: storage: reconcile manual splitting with automatic merging r=jeffrey-xiao a=jeffrey-xiao Follows the steps outlined in #37487 to reconcile manual splitting with automatic merging. This PR includes the changes needed at the storage layer. The sticky bit indicating that a range is manually split is added to the range descriptor. 37558: docs/tla-plus: add timestamp refreshes to ParallelCommits spec r=nvanbenschoten a=nvanbenschoten This commit adds transaction timestamp refreshes to the PlusCal model for parallel commits. This allows the committing transaction to bump its timestamp without a required epoch bump. This completes the parallel commits formal specification. 37578: opt, sql: fix type inference of TypeCheck for subqueries r=rytaft a=rytaft Prior to this commit, the optimizer was not correctly inferring the types of columns in subqueries for expressions of the form `scalar IN (subquery)`. This was due to two problems which have now been fixed: 1. The subquery was built as a relational expression before the desired types were known. Now the subquery build is delayed until `TypeCheck` is called for the first time. 2. For subqueries on the right side of an `IN` expression, the desired type passed into `TypeCheck` was `AnyTuple`. This resulted in an error later on in `typeCheckSubqueryWithIn`, which checks to make sure the type of the subquery is `tuple{T}` where `T` is the type of the left expression. Now the desired type passed into `TypeCheck` is `tuple{T}`. Note that this commit only fixes type inference for the optimizer. It is still broken in the heuristic planner. Fixes #37263 Fixes #14554 Release note (bug fix): Fixed type inference of columns in subqueries for some expressions of the form `scalar IN (subquery)`. Co-authored-by: Jeffrey Xiao <jeffrey.xiao1998@gmail.com> Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com> Co-authored-by: Rebecca Taft <becca@cockroachlabs.com>
Prior to this commit, the optimizer was not correctly inferring the types of columns in subqueries for expressions of the form `scalar IN (subquery)`. This was due to two problems which have now been fixed: 1. The subquery was built as a relational expression before the desired types were known. Now the subquery build is delayed until TypeCheck is called for the first time. 2. For subqueries on the right side of an IN expression, the desired type passed into TypeCheck was FamTuple. This resulted in an error later on in typeCheckSubqueryWithIn, which checks to make sure the type of the subquery is tuple{T} where T is the type of the left expression. Now the desired type passed into TypeCheck is tuple{T}. Note that this commit only fixes type inference for the optimizer. It is still broken in the heuristic planner. Fixes cockroachdb#37263 Fixes cockroachdb#14554 Release note (bug fix): Fixed type inference of columns in subqueries for some expressions of the form `scalar IN (subquery)`.
The latest version of CockroachDB comes with full support for correlated subqueries which was an issue before. Now the only stoper is one sql fragment where an explicity cast is currently needed. See: cockroachdb/cockroach#14554
As discussed with @jordanlewis in #12526, I believe the recent work on supporting the OID type created a small regression with the following error:
sql/executor.go:722 [client=127.0.0.1:63505,user=root,n1] execRequest: error: unsupported comparison operator: <oid> NOT IN <tuple{int}>
Looks like there are some missing comparison operators between OID and int type now that OIDs are not int anymore.
The text was updated successfully, but these errors were encountered: