-
Notifications
You must be signed in to change notification settings - Fork 17
PrepareRequest "Parameter Unbound" Error (Join Only Takes Params from One Table) #7
Comments
I also found that post in Hortonworks community, SELECT fact0.CustomerId FROM ShippingGlobalCodes gcD1 INNER JOIN ShippingCodeFact fact0 ON fact0.StringData = gcD1.InternalCode WHERE gcD1.GlobalCode = ? SELECT fact0.CustomerId FROM ShippingCodeFact fact0 INNER JOIN ShippingGlobalCodes gcD1 ON fact0.StringData = gcD1.InternalCode WHERE fact0.StartDate < ? AND fact0.EndDate >= ? Both of above works, the pattern looks like if A INNER JOIN B, in where statement, you can use A's fields, but not B's fields, I am not sure if this is the Phoenix syntax, I will confirm with Hortonworks. |
So to clarify, this is just a limitation of Phoenix's SQL implementation? |
I ran the INNER JOIN query in PrepareAndExecuteRequest as well as sqlline.py on the cluster, both were executed successfully. So Phoenix should have supported this syntax. The error is from Calcite/Avatica when we executed PrepareRequest, I think the bug is from there. The Hortonworks dev owner of PQS is out of office and I will contact him again next Monday. BTW, when you executed your subquery, did that show the same stack trace or different? Could you provide me a sample query? |
@duoxu "SELECT CustomerId FROM (SELECT * FROM ShippingCodeFact fact0 INNER JOIN ShippingGlobalCodes gcD1 ON fact0.StringData = gcD1.InternalCode) WHERE StartDate < ? AND EndDate >= ? AND GlobalCode = ?" I also looked at doing a query like this: I was hoping that separating the filtering from the join would avoid the problem, but based on the results I'm assuming that somewhere before it gets to the bug, Phoenix is translating/optimizing these queries into something equivalent to the original version we tried. |
When we try to use parameters in a more-complicated query (we think specifically when we use joins), our code fails at PrepareRequestAsync(), returning an exception that a parameter is unbound- which to us seems very strange, since we don't want to bind any parameters until we're going to call ExecuteRequestAsync().
We assume that we are doing something wrong in our code, but if that is not the case, we suspect this is a problem in Phoenix or even Calcite. We found this (identical?) problem on the Hortonworks Community forum, unresolved: https://community.hortonworks.com/questions/45896/problem-executing-joins-on-phoenix-query-server.html. It links to [CALCITE-1052]- I can't tell if this is really related- at the very least, the connectionId in our error message matches the connectionId of our PrepareRequest, which it sounds like wasn't true for them. Regardless, their issue was apparently solved by updating to Phoenix 4.7, and I believe we are running 4.4, so if someone with a newer version can confirm that this isn't reproducible in 4.7, I'll make the requests to get our install updated to that.
Table Setup:
DROP TABLE IF EXISTS ShippingCodeFact;
CREATE TABLE IF NOT EXISTS ShippingCodeFact (
CodeId DECIMAL (18, 0),
StringData VARCHAR,
CodeKey BIGINT NOT NULL,
CustomerId VARCHAR,
StartDate TIMESTAMP,
EndDate TIMESTAMP,
CONSTRAINT my_pk PRIMARY KEY(CodeId, StringData, CodeKey)
) SALT_BUCKETS=32, COMPRESSION='GZ';
DROP TABLE IF EXISTS ShippingGlobalCodes;
CREATE TABLE IF NOT EXISTS ShippingGlobalCodes (
GlobalCode VARCHAR,
InternalCode VARCHAR,
CodeName VARCHAR,
CodeKey BIGINT NOT NULL
CONSTRAINT my_pk PRIMARY KEY(GlobalCode, InternalCode, CodeKey)
) SALT_BUCKETS=32;
Code:
Exception "errorMessage":
RuntimeException: java.sql.SQLException: ERROR 2004 (INT05): Parameter value unbound Parameter at index 3 is unbound -\u003e SQLException: ERROR 2004 (INT05): Parameter value unbound Parameter at index 3 is unbound
(If anyone wants I can paste the whole "exceptions" value- most of it is just the trace)
@duoxu since you've seemed interested in the other issues
The text was updated successfully, but these errors were encountered: