Skip to content

Commit bfa4bc0

Browse files
committed
Address comments
Use `StandardTypes` to check the type of the procedure arguments Throw a `PrestoException` with error code of `INVALID_ARGUMENTS` rather than an IAE
1 parent 3378751 commit bfa4bc0

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

presto-spi/src/main/java/com/facebook/presto/spi/procedure/BaseProcedure.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
package com.facebook.presto.spi.procedure;
1515

1616
import com.facebook.presto.common.type.TypeSignature;
17+
import com.facebook.presto.spi.PrestoException;
1718
import jakarta.annotation.Nullable;
1819

1920
import java.util.ArrayList;
@@ -22,6 +23,7 @@
2223
import java.util.Set;
2324

2425
import static com.facebook.presto.common.type.TypeSignature.parseTypeSignature;
26+
import static com.facebook.presto.spi.StandardErrorCode.INVALID_ARGUMENTS;
2527
import static java.lang.String.format;
2628
import static java.util.Collections.unmodifiableList;
2729
import static java.util.Locale.ENGLISH;
@@ -150,7 +152,7 @@ private static String checkNotNullOrEmpty(String value, String name)
150152
protected static void checkArgument(boolean assertion, String message)
151153
{
152154
if (!assertion) {
153-
throw new IllegalArgumentException(message);
155+
throw new PrestoException(INVALID_ARGUMENTS, message);
154156
}
155157
}
156158
}

presto-spi/src/main/java/com/facebook/presto/spi/procedure/TableDataRewriteDistributedProcedure.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.OptionalInt;
2525
import java.util.function.Supplier;
2626

27+
import static com.facebook.presto.common.type.StandardTypes.VARCHAR;
2728
import static com.facebook.presto.spi.procedure.DistributedProcedure.DistributedProcedureType.TABLE_DATA_REWRITE;
2829
import static java.lang.String.format;
2930
import static java.util.Objects.requireNonNull;
@@ -54,12 +55,12 @@ public TableDataRewriteDistributedProcedure(String schema, String name,
5455
this.contextSupplier = requireNonNull(contextSupplier, "contextSupplier is null");
5556
for (int i = 0; i < getArguments().size(); i++) {
5657
if (getArguments().get(i).getName().equals(SCHEMA)) {
57-
checkArgument(getArguments().get(i).getType().toString().equalsIgnoreCase("varchar"),
58+
checkArgument(getArguments().get(i).getType().getBase().equals(VARCHAR),
5859
format("Argument `%s` must be string type", SCHEMA));
5960
schemaIndex = i;
6061
}
6162
else if (getArguments().get(i).getName().equals(TABLE_NAME)) {
62-
checkArgument(getArguments().get(i).getType().toString().equalsIgnoreCase("varchar"),
63+
checkArgument(getArguments().get(i).getType().getBase().equals(VARCHAR),
6364
format("Argument `%s` must be string type", TABLE_NAME));
6465
tableNameIndex = i;
6566
}

0 commit comments

Comments
 (0)