Skip to content

Commit

Permalink
Fix bugs with @IsNull
Browse files Browse the repository at this point in the history
- Add boolean.class to stackTypes when passing parameter for @IsNull
- Get the correct parameter type list after binding ConnectorSession
  • Loading branch information
geraint0923 committed Oct 11, 2016
1 parent fc72ac5 commit 9b852cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,14 @@ public static BytecodeNode generateInvocation(Scope scope, String name, ScalarFu
checkArgument(instance.isPresent());
}

// Index of current parameter in the MethodHandle
int currentParameterIndex = 0;

// Index of parameter (without @IsNull) in Presto function
int realParameterIndex = 0;

boolean boundInstance = false;
while (currentParameterIndex < methodType.parameterArray().length) {
//for (Class<?> type : methodType.parameterArray()) {
Class<?> type = methodType.parameterArray()[currentParameterIndex];
stackTypes.add(type);
if (function.getInstanceFactory().isPresent() && !boundInstance) {
Expand All @@ -197,6 +200,7 @@ else if (type == ConnectorSession.class) {
else {
if (function.getNullFlags().get(realParameterIndex)) {
block.append(scope.getVariable("wasNull"));
stackTypes.add(boolean.class);
currentParameterIndex++;
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ public static Object invoke(ConnectorSession session, ScalarFunctionImplementati
}
try {
List<Object> actualArguments = new ArrayList<>();
Class<?>[] parameterArray = function.getMethodHandle().type().parameterArray();
Class<?>[] parameterArray = handle.type().parameterArray();
for (int i = 0; i < argumentValues.size(); i++) {
Object argument = argumentValues.get(i);
if (function.getNullFlags().get(i)) {
Expand Down

0 comments on commit 9b852cb

Please sign in to comment.