|
14 | 14 | package com.facebook.presto.sidecar; |
15 | 15 |
|
16 | 16 | import com.facebook.airlift.units.DataSize; |
| 17 | +import com.facebook.presto.Session; |
17 | 18 | import com.facebook.presto.nativeworker.PrestoNativeQueryRunnerUtils; |
18 | 19 | import com.facebook.presto.sidecar.functionNamespace.FunctionDefinitionProvider; |
19 | 20 | import com.facebook.presto.sidecar.functionNamespace.NativeFunctionDefinitionProvider; |
|
44 | 45 | import java.util.stream.Collectors; |
45 | 46 |
|
46 | 47 | import static com.facebook.airlift.units.DataSize.Unit.MEGABYTE; |
| 48 | +import static com.facebook.presto.SystemSessionProperties.REMOVE_MAP_CAST; |
47 | 49 | import static com.facebook.presto.common.Utils.checkArgument; |
48 | 50 | import static com.facebook.presto.common.type.BigintType.BIGINT; |
49 | 51 | import static com.facebook.presto.nativeworker.NativeQueryRunnerUtils.createLineitem; |
@@ -405,6 +407,22 @@ public void testGeometryQueries() |
405 | 407 | "Error from native plan checker: .SpatialJoinNode no abstract type PlanNode "); |
406 | 408 | } |
407 | 409 |
|
| 410 | + @Test |
| 411 | + public void testRemoveMapCast() |
| 412 | + { |
| 413 | + Session enableOptimization = Session.builder(getSession()) |
| 414 | + .setSystemProperty(REMOVE_MAP_CAST, "true") |
| 415 | + .build(); |
| 416 | + assertQuery(enableOptimization, "select feature[key] from (values (map(array[cast(1 as integer), 2, 3, 4], array[0.3, 0.5, 0.9, 0.1]), cast(2 as bigint)), (map(array[cast(1 as integer), 2, 3, 4], array[0.3, 0.5, 0.9, 0.1]), 4)) t(feature, key)", |
| 417 | + "values 0.5, 0.1"); |
| 418 | + assertQuery(enableOptimization, "select element_at(feature, key) from (values (map(array[cast(1 as integer), 2, 3, 4], array[0.3, 0.5, 0.9, 0.1]), cast(2 as bigint)), (map(array[cast(1 as integer), 2, 3, 4], array[0.3, 0.5, 0.9, 0.1]), 4)) t(feature, key)", |
| 419 | + "values 0.5, 0.1"); |
| 420 | + assertQuery(enableOptimization, "select element_at(feature, key) from (values (map(array[cast(1 as integer), 2, 3, 4], array[0.3, 0.5, 0.9, 0.1]), cast(2 as bigint)), (map(array[cast(1 as integer), 2, 3, 4], array[0.3, 0.5, 0.9, 0.1]), 400000000000)) t(feature, key)", |
| 421 | + "values 0.5, null"); |
| 422 | + assertQuery(enableOptimization, "select feature[key] from (values (map(array[cast(1 as varchar), '2', '3', '4'], array[0.3, 0.5, 0.9, 0.1]), cast('2' as varchar)), (map(array[cast(1 as varchar), '2', '3', '4'], array[0.3, 0.5, 0.9, 0.1]), '4')) t(feature, key)", |
| 423 | + "values 0.5, 0.1"); |
| 424 | + } |
| 425 | + |
408 | 426 | private String generateRandomTableName() |
409 | 427 | { |
410 | 428 | String tableName = "tmp_presto_" + UUID.randomUUID().toString().replace("-", ""); |
|
0 commit comments