http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/10fa472f/be/src/udf/udf.h ---------------------------------------------------------------------- diff --git a/be/src/udf/udf.h b/be/src/udf/udf.h index e6ec07c..461482c 100644 --- a/be/src/udf/udf.h +++ b/be/src/udf/udf.h @@ -606,17 +606,18 @@ struct StringVal : public AnyVal { struct DecimalVal : public impala_udf::AnyVal { /// Decimal data is stored as an unscaled integer value. For example, the decimal 1.00 - /// (precison 3, scale 2) is stored as 100. The byte size necessary to store the decimal - /// depends on the precision, which determines which field of the union should be used to - /// store and manipulate the unscaled value. - // + /// (precision 3, scale 2) is stored as 100. The byte size necessary to store the + /// decimal depends on the precision, which determines which field of the union should + /// be used to store and manipulate the unscaled value. + /// /// precision between 0-9: val4 (4 bytes) /// precision between 10-18: val8 (8 bytes) /// precision between 19-38: val16 (16 bytes) - // + /// /// While it is always safe to use a larger field than necessary, it may result in worse - /// performance. For example, a UDF that only uses val16 can handle any precision but may - /// be slower than one that uses val4 or val8. + /// performance. For example, a UDF that only uses val16 can handle any precision but + /// may be slower than one that uses val4 or val8. This is because the least-significant + /// bits of all three union fields are the same (assuming a little-endian architecture). union { int32_t val4; int64_t val8;
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/10fa472f/be/src/util/bit-util.h ---------------------------------------------------------------------- diff --git a/be/src/util/bit-util.h b/be/src/util/bit-util.h index 9a5c4a4..deb16a9 100644 --- a/be/src/util/bit-util.h +++ b/be/src/util/bit-util.h @@ -72,7 +72,7 @@ class BitUtil { /// Returns 'value' rounded up to the nearest multiple of 'factor' when factor is /// a power of two - static inline int RoundUpToPowerOf2(int value, int factor) { + static inline int64_t RoundUpToPowerOf2(int64_t value, int64_t factor) { DCHECK((factor > 0) && ((factor & (factor - 1)) == 0)); return (value + (factor - 1)) & ~(factor - 1); } http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/10fa472f/testdata/workloads/functional-query/queries/QueryTest/exprs.test ---------------------------------------------------------------------- diff --git a/testdata/workloads/functional-query/queries/QueryTest/exprs.test b/testdata/workloads/functional-query/queries/QueryTest/exprs.test index 3c7f5d5..ba8d4fb 100644 --- a/testdata/workloads/functional-query/queries/QueryTest/exprs.test +++ b/testdata/workloads/functional-query/queries/QueryTest/exprs.test @@ -803,6 +803,35 @@ NULL boolean ==== ---- QUERY +# In predicate with strings +select int_col, string_col from alltypesagg +where string_col in ('212', '768', '1242', '124141', '0000', '99999') +order by int_col limit 20 +---- RESULTS +212,'212' +212,'212' +212,'212' +212,'212' +212,'212' +212,'212' +212,'212' +212,'212' +212,'212' +212,'212' +768,'768' +768,'768' +768,'768' +768,'768' +768,'768' +768,'768' +768,'768' +768,'768' +768,'768' +768,'768' +---- TYPES +int,string +==== +---- QUERY select count(*) from alltypesagg where true in (bool_col, tinyint_col) ---- RESULTS http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/10fa472f/testdata/workloads/functional-query/queries/QueryTest/uda.test ---------------------------------------------------------------------- diff --git a/testdata/workloads/functional-query/queries/QueryTest/uda.test b/testdata/workloads/functional-query/queries/QueryTest/uda.test index 8572e8c..21877cf 100644 --- a/testdata/workloads/functional-query/queries/QueryTest/uda.test +++ b/testdata/workloads/functional-query/queries/QueryTest/uda.test @@ -34,3 +34,10 @@ select trunc_sum(double_col),sum(double_col) from functional_parquet.alltypes wh ---- TYPES bigint,double ==== +---- QUERY +select arg_is_const(int_col, 1) from functional_parquet.alltypes; +---- RESULTS +true +---- TYPES +boolean +==== http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/10fa472f/testdata/workloads/targeted-perf/queries/primitive_filter_in_predicate.test ---------------------------------------------------------------------- diff --git a/testdata/workloads/targeted-perf/queries/primitive_filter_in_predicate.test b/testdata/workloads/targeted-perf/queries/primitive_filter_in_predicate.test new file mode 100644 index 0000000..c10b48a --- /dev/null +++ b/testdata/workloads/targeted-perf/queries/primitive_filter_in_predicate.test @@ -0,0 +1,10 @@ +==== +---- QUERY: primitive_filter_in_predicate +-- Description : Scan fact table while applying selective in predicate filter. +-- Target test case : Basic scan and filter. +SELECT count(*) +FROM lineitem +WHERE l_partkey in (1,6,11,16,21,26,31,36,41,46,51,56,61,66,71,76,81,86,91,96,101,106,111,116,121,126,131,136,141,146,151,156,161,166,171,176,181,186,191,196,201,206,211,216,221,226,231,236,241,246,251,256,261,266,271,276,281,286,291,296,301,306,311,316,321,326,331,336,341,346,351,356,361,366,371,376,381,386,391,396,401,406,411,416,421,426,431,436,441,446,451,456,461,466,471,476,481,486,491,496,501,506,511,516,521,526,531,536,541,546,551,556,561,566,571,576,581,586,591,596,601,606,611,616,621,626,631,636,641,646,651,656,661,666,671,676,681,686,691,696,701,706,711,716,721,726,731,736,741,746,751,756,761,766,771,776,781,786,791,796,801,806,811,816,821,826,831,836,841,846,851,856,861,866,871,876,881,886,891,896,901,906,911,916,921,926,931,936,941,946,951,956,961,966,971,976,981,986,991,996,1001,1006,1011,1016,1021,1026,1031,1036,1041,1046,1051,1056,1061,1066,1071,1076,1081,1086,1091,1096,1101,1106,1111,1116,1121,1126,1131,1136,1141,1146,1151,1156,1161,1166,1171,1176,1181,1186,1191,1196 ,1201,1206,1211,1216,1221,1226,1231,1236,1241,1246,1251,1256,1261,1266,1271,1276,1281,1286,1291,1296,1301,1306,1311,1316,1321,1326,1331,1336,1341,1346,1351,1356,1361,1366,1371,1376,1381,1386,1391,1396,1401,1406,1411,1416,1421,1426,1431,1436,1441,1446,1451,1456,1461,1466,1471,1476,1481,1486,1491,1496,1501,1506,1511,1516,1521,1526,1531,1536,1541,1546,1551,1556,1561,1566,1571,1576,1581,1586,1591,1596,1601,1606,1611,1616,1621,1626,1631,1636,1641,1646,1651,1656,1661,1666,1671,1676,1681,1686,1691,1696,1701,1706,1711,1716,1721,1726,1731,1736,1741,1746,1751,1756,1761,1766,1771,1776,1781,1786,1791,1796,1801,1806,1811,1816,1821,1826,1831,1836,1841,1846,1851,1856,1861,1866,1871,1876,1881,1886,1891,1896,1901,1906,1911,1916,1921,1926,1931,1936,1941,1946,1951,1956,1961,1966,1971,1976,1981,1986,1991,1996,2001,2006,2011,2016,2021,2026,2031,2036,2041,2046,2051,2056,2061,2066,2071,2076,2081,2086,2091,2096,2101,2106,2111,2116,2121,2126,2131,2136,2141,2146,2151,2156,2161,2166,2171,2176,2181,2186,2191,2 196,2201,2206,2211,2216,2221,2226,2231,2236,2241,2246,2251,2256,2261,2266,2271,2276,2281,2286) +---- RESULTS +---- TYPES +==== http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/10fa472f/tests/query_test/test_udfs.py ---------------------------------------------------------------------- diff --git a/tests/query_test/test_udfs.py b/tests/query_test/test_udfs.py index 2658351..0497cbd 100644 --- a/tests/query_test/test_udfs.py +++ b/tests/query_test/test_udfs.py @@ -329,6 +329,7 @@ returns decimal(9,2) location '{location}' update_fn='SumSmallDecimalUpdate'; # Create test UDA functions in {database} from library {location} create_test_udas_template = """ drop function if exists {database}.trunc_sum(double); +drop function if exists {database}.arg_is_const(int, int); create database if not exists {database}; @@ -336,6 +337,10 @@ create aggregate function {database}.trunc_sum(double) returns bigint intermediate double location '{location}' update_fn='TruncSumUpdate' merge_fn='TruncSumMerge' serialize_fn='TruncSumSerialize' finalize_fn='TruncSumFinalize'; + +create aggregate function {database}.arg_is_const(int, int) +returns boolean location '{location}' +init_fn='ArgIsConstInit' update_fn='ArgIsConstUpdate' merge_fn='ArgIsConstMerge'; """ # Create test UDF functions in {database} from library {location}
