Skip to content

Commit

Permalink
Extend SHOW FUNCTIONS to display whether functions have variable arity
Browse files Browse the repository at this point in the history
  • Loading branch information
caithagoras0 authored and Rongrong Zhong committed Jan 27, 2020
1 parent 283e300 commit c3b0432
Show file tree
Hide file tree
Showing 12 changed files with 279 additions and 266 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.facebook.presto.spi.StandardErrorCode;
import com.facebook.presto.spi.TableHandle;
import com.facebook.presto.spi.function.FunctionKind;
import com.facebook.presto.spi.function.Signature;
import com.facebook.presto.spi.function.SqlFunction;
import com.facebook.presto.spi.security.PrestoPrincipal;
import com.facebook.presto.spi.security.PrincipalType;
Expand Down Expand Up @@ -525,15 +526,17 @@ protected Node visitShowFunctions(ShowFunctions node, Void context)
{
ImmutableList.Builder<Expression> rows = ImmutableList.builder();
for (SqlFunction function : metadata.listFunctions(session)) {
Signature signature = function.getSignature();
rows.add(row(
function.getSignature().getName().getFunctionNamespace().equals(DEFAULT_NAMESPACE) ?
new StringLiteral(function.getSignature().getNameSuffix()) :
new StringLiteral(function.getSignature().getName().toString()),
new StringLiteral(function.getSignature().getReturnType().toString()),
new StringLiteral(Joiner.on(", ").join(function.getSignature().getArgumentTypes())),
signature.getName().getFunctionNamespace().equals(DEFAULT_NAMESPACE) ?
new StringLiteral(signature.getNameSuffix()) :
new StringLiteral(signature.getName().toString()),
new StringLiteral(signature.getReturnType().toString()),
new StringLiteral(Joiner.on(", ").join(signature.getArgumentTypes())),
new StringLiteral(getFunctionType(function)),
function.isDeterministic() ? TRUE_LITERAL : FALSE_LITERAL,
new StringLiteral(nullToEmpty(function.getDescription()))));
new StringLiteral(nullToEmpty(function.getDescription())),
signature.isVariableArity() ? TRUE_LITERAL : FALSE_LITERAL));
}

Map<String, String> columns = ImmutableMap.<String, String>builder()
Expand All @@ -543,6 +546,7 @@ protected Node visitShowFunctions(ShowFunctions node, Void context)
.put("function_type", "Function Type")
.put("deterministic", "Deterministic")
.put("description", "Description")
.put("variable_arity", "Variable Arity")
.build();

return simpleQuery(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
-- delimiter: |; ignoreOrder: true; ignoreExcessRows: true; trimValues:true
concat | array(E) | E, array(E) | scalar | true | Concatenates an element to an array |
concat | array(E) | array(E), E | scalar | true | Concatenates an array to an element |
concat | array(E) | array(E) | scalar | true | Concatenates given arrays |
cardinality | bigint | array(E) | scalar | true | Returns the cardinality (length) of the array |
contains | boolean | array(T), T | scalar | true | Determines whether given value exists in the array |
array_sort | array(E) | array(E) | scalar | true | Sorts the given array in ascending order according to the natural ordering of its elements. |
array_sort | array(T) | array(T), function(T,T,integer) | scalar | true | Sorts the given array with a lambda comparator. |
array_intersect | array(E) | array(E), array(E) | scalar | true | Intersects elements of the two given arrays |
array_distinct | array(E) | array(E) | scalar | true | Remove duplicate values from the given array |
concat | array(E) | E, array(E) | scalar | true | Concatenates an element to an array | false |
concat | array(E) | array(E), E | scalar | true | Concatenates an array to an element | false |
concat | array(E) | array(E) | scalar | true | Concatenates given arrays | true |
cardinality | bigint | array(E) | scalar | true | Returns the cardinality (length) of the array | false |
contains | boolean | array(T), T | scalar | true | Determines whether given value exists in the array | false |
array_sort | array(E) | array(E) | scalar | true | Sorts the given array in ascending order according to the natural ordering of its elements. | false |
array_sort | array(T) | array(T), function(T,T,integer) | scalar | true | Sorts the given array with a lambda comparator. | false |
array_intersect | array(E) | array(E), array(E) | scalar | true | Intersects elements of the two given arrays | false |
array_distinct | array(E) | array(E) | scalar | true | Remove duplicate values from the given array | false |
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
-- delimiter: |; ignoreOrder: true; ignoreExcessRows: true; trimValues:true
length | bigint | varbinary | scalar | true | length of the given binary |
to_base64 | varchar | varbinary | scalar | true | encode binary data as base64 |
to_base64url | varchar | varbinary | scalar | true | encode binary data as base64 using the URL safe alphabet |
to_hex | varchar | varbinary | scalar | true | encode binary data as hex |
from_base64 | varbinary | varbinary | scalar | true | decode base64 encoded binary data |
from_base64 | varbinary | varchar(x) | scalar | true | decode base64 encoded binary data |
from_base64url | varbinary | varbinary | scalar | true | decode URL safe base64 encoded binary data |
from_base64url | varbinary | varchar(x) | scalar | true | decode URL safe base64 encoded binary data |
length | bigint | varbinary | scalar | true | length of the given binary | false |
to_base64 | varchar | varbinary | scalar | true | encode binary data as base64 | false |
to_base64url | varchar | varbinary | scalar | true | encode binary data as base64 using the URL safe alphabet | false |
to_hex | varchar | varbinary | scalar | true | encode binary data as hex | false |
from_base64 | varbinary | varbinary | scalar | true | decode base64 encoded binary data | false |
from_base64 | varbinary | varchar(x) | scalar | true | decode base64 encoded binary data | false |
from_base64url | varbinary | varbinary | scalar | true | decode URL safe base64 encoded binary data | false |
from_base64url | varbinary | varchar(x) | scalar | true | decode URL safe base64 encoded binary data | false |
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- delimiter: |; ignoreOrder: true; ignoreExcessRows:true; trimValues:true;
abs | bigint | bigint | scalar | true | absolute value |
abs | double | double | scalar | true | absolute value |
acos | double | double | scalar | true | arc cosine |
abs | bigint | bigint | scalar | true | absolute value | false |
abs | double | double | scalar | true | absolute value | false |
acos | double | double | scalar | true | arc cosine | false |
Loading

0 comments on commit c3b0432

Please sign in to comment.