|
30 | 30 | import com.facebook.presto.common.type.MapType;
|
31 | 31 | import com.facebook.presto.common.type.RowType;
|
32 | 32 | import com.facebook.presto.common.type.Type;
|
| 33 | +import com.facebook.presto.common.type.TypeSignature; |
33 | 34 | import com.facebook.presto.common.type.TypeSignatureParameter;
|
34 | 35 | import com.facebook.presto.common.type.TypeUtils;
|
35 | 36 | import com.facebook.presto.common.type.TypeWithName;
|
|
154 | 155 | import static com.facebook.presto.common.type.VarcharType.VARCHAR;
|
155 | 156 | import static com.facebook.presto.metadata.BuiltInTypeAndFunctionNamespaceManager.JAVA_BUILTIN_NAMESPACE;
|
156 | 157 | import static com.facebook.presto.spi.StandardErrorCode.OPERATOR_NOT_FOUND;
|
| 158 | +import static com.facebook.presto.spi.StandardWarningCode.PERFORMANCE_WARNING; |
157 | 159 | import static com.facebook.presto.spi.StandardWarningCode.SEMANTIC_WARNING;
|
158 | 160 | import static com.facebook.presto.sql.NodeUtils.getSortItemsFromOrderBy;
|
159 | 161 | import static com.facebook.presto.sql.analyzer.Analyzer.verifyNoAggregateWindowOrGroupingFunctions;
|
@@ -1119,6 +1121,34 @@ else if (frame.getType() == GROUPS) {
|
1119 | 1121 | }
|
1120 | 1122 | }
|
1121 | 1123 |
|
| 1124 | + List<TypeSignature> arguments = functionMetadata.getArgumentTypes(); |
| 1125 | + String functionName = functionMetadata.getName().toString(); |
| 1126 | + |
| 1127 | + if (!argumentTypes.isEmpty() && "map".equals(arguments.get(0).getBase())) { |
| 1128 | + if (arguments.size() > 1) { |
| 1129 | + arguments.stream() |
| 1130 | + .skip(1) |
| 1131 | + .filter(arg -> { |
| 1132 | + String base = arg.getBase(); |
| 1133 | + return "function".equals(base) || "lambda".equals(base); |
| 1134 | + }) |
| 1135 | + .findFirst() |
| 1136 | + .ifPresent(arg -> { |
| 1137 | + String warningMessage = createWarningMessage(node, |
| 1138 | + String.format("Function '%s' uses a lambda on large maps which is expensive. Consider using map_subset", functionName)); |
| 1139 | + warningCollector.add(new PrestoWarning(PERFORMANCE_WARNING, warningMessage)); |
| 1140 | + } |
| 1141 | + ); |
| 1142 | + } else if (arguments.size() == 1) { |
| 1143 | + String base = arguments.get(0).getBase(); |
| 1144 | + if ("function".equals(base) || "lambda".equals(base)) { |
| 1145 | + String warningMessage = createWarningMessage(node, |
| 1146 | + String.format("Function '%s' uses a lambda on large maps which is expensive. Consider using map_subset", functionName)); |
| 1147 | + warningCollector.add(new PrestoWarning(PERFORMANCE_WARNING, warningMessage)); |
| 1148 | + } |
| 1149 | + } |
| 1150 | + } |
| 1151 | + |
1122 | 1152 | if (node.isIgnoreNulls() && node.getWindow().isPresent()) {
|
1123 | 1153 | if (!functionResolution.isWindowValueFunction(function)) {
|
1124 | 1154 | String warningMessage = createWarningMessage(node, "IGNORE NULLS is not used for aggregate and ranking window functions. This will cause queries to fail in future versions.");
|
|
0 commit comments