-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix incorrect order for parameters in DESCRIBE INPUT #14914
Conversation
@@ -32,7 +32,7 @@ | |||
{ | |||
private ParameterUtils() {} | |||
|
|||
public static Map<NodeRef<Parameter>, Expression> parameterExtractor(Statement statement, List<Expression> parameters) | |||
public static Map<NodeRef<Parameter>, Expression> bindParameters(Statement statement, List<Expression> parameters) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we be a bit more specific here like bindParametersToExpression
the method name might mislead us ParameterRewriter
- where we bind the parameter
to expression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the "toExpression" suffix adds much value. Although, it'd be clearer if the second argument were named "values" instead of parameters -- the parameters are in the query itself.
@@ -2070,8 +2070,8 @@ protected Type visitParameter(Parameter node, StackableAstVisitorContext<Context | |||
if (parameters.size() == 0) { | |||
throw semanticException(INVALID_PARAMETER_USAGE, node, "Query takes no parameters"); | |||
} | |||
if (node.getPosition() >= parameters.size()) { | |||
throw semanticException(INVALID_PARAMETER_USAGE, node, "Invalid parameter index %s, max value is %s", node.getPosition(), parameters.size() - 1); | |||
if (node.getId() >= parameters.size()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if it is some sort of a uniqueId (which I totally agree) then comparing getId
but parameters
size would make less sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's sort of true, unless we define the ids as being from 0 to the number of parameters in the query. I hesitated removing these checks, but I do agree they look wonky. Let me see if there's a better way to represent them, or I'll just remove them.
The position does not actually match the order in which they are supposed to be processed. It's needed just to assign a unique identity to each parameter node.
They were being listed in depth-first-search order instead of in the order in which they appear in the query text.
82c3b05
to
a2e9d47
Compare
The parameters were being listed in depth-first-search order instead of in the order in which they appear in the query text.
Fixes #14738
Release notes
(x) Release notes are required, please propose a release note for me.