@@ -1295,14 +1295,6 @@ TRACED_TEST(AsofJoinTest, TestUnsupportedByType, {
12951295 field (" r0_v0" , float32 ())}));
12961296})
12971297
1298- TRACED_TEST(AsofJoinTest, TestUnsupportedDatatype, {
1299- // List is unsupported
1300- DoRunInvalidTypeTest (
1301- schema ({field (" time" , int64 ()), field (" key" , int32 ()), field (" l_v0" , float64 ())}),
1302- schema ({field (" time" , int64 ()), field (" key" , int32 ()),
1303- field (" r0_v0" , list (int32 ()))}));
1304- })
1305-
13061298TRACED_TEST(AsofJoinTest, TestMissingKeys, {
13071299 DoRunMissingKeysTest (
13081300 schema ({field (" time1" , int64 ()), field (" key" , int32 ()), field (" l_v0" , float64 ())}),
@@ -1910,5 +1902,131 @@ TEST(AsofJoinTest, OneSideTsAllGreaterThanTheOther) {
19101902 }
19111903}
19121904
1905+ // GH-44729: Testing nested data type for non-key fields
1906+ TEST (AsofJoinTest, FixedListDataType) {
1907+ const int32_t list_size = 3 ;
1908+ auto list_type = arrow::fixed_size_list (arrow::int32 (), list_size);
1909+
1910+ auto left_batch = ExecBatchFromJSON ({int64 ()}, R"( [[1], [2], [3]])" );
1911+ auto right_batch = ExecBatchFromJSON ({list_type, int64 ()}, R"( [
1912+ [[0, 1, 2], 2],
1913+ [[3, 4, 5], 3],
1914+ [[6, 7, 8], 4]
1915+ ])" );
1916+
1917+ Declaration left{" exec_batch_source" ,
1918+ ExecBatchSourceNodeOptions (schema ({field (" on" , int64 ())}),
1919+ {std::move (left_batch)})};
1920+ Declaration right{" exec_batch_source" ,
1921+ ExecBatchSourceNodeOptions (
1922+ schema ({field (" colVals" , list_type), field (" on" , int64 ())}),
1923+ {std::move (right_batch)})};
1924+
1925+ AsofJoinNodeOptions asof_join_opts ({{{" on" }, {}}, {{" on" }, {}}}, 1 );
1926+ Declaration asof_join{
1927+ " asofjoin" , {std::move (left), std::move (right)}, std::move (asof_join_opts)};
1928+
1929+ ASSERT_OK_AND_ASSIGN (auto result, DeclarationToExecBatches (std::move (asof_join)));
1930+
1931+ auto exp_batch = ExecBatchFromJSON ({int64 (), list_type}, R"( [
1932+ [1, [0, 1, 2]],
1933+ [2, [0, 1, 2]],
1934+ [3, [3, 4, 5]]
1935+ ])" );
1936+
1937+ AssertExecBatchesEqual (result.schema , {exp_batch}, result.batches );
1938+ }
1939+
1940+ TEST (AsofJoinTest, ListDataType) {
1941+ auto list_type = list (int32 ());
1942+
1943+ auto left_batch = ExecBatchFromJSON ({int64 ()}, R"( [[1], [2], [3]])" );
1944+ auto right_batch = ExecBatchFromJSON ({list_type, int64 ()}, R"( [
1945+ [[0, 1, 2, 9], 2],
1946+ [[3, 4, 5, 7], 3],
1947+ [[6, 7, 8], 4]
1948+ ])" );
1949+
1950+ Declaration left{" exec_batch_source" ,
1951+ ExecBatchSourceNodeOptions (schema ({field (" on" , int64 ())}),
1952+ {std::move (left_batch)})};
1953+ Declaration right{" exec_batch_source" ,
1954+ ExecBatchSourceNodeOptions (
1955+ schema ({field (" colVals" , list_type), field (" on" , int64 ())}),
1956+ {std::move (right_batch)})};
1957+
1958+ AsofJoinNodeOptions asof_join_opts ({{{" on" }, {}}, {{" on" }, {}}}, 1 );
1959+ Declaration asof_join{
1960+ " asofjoin" , {std::move (left), std::move (right)}, std::move (asof_join_opts)};
1961+
1962+ ASSERT_OK_AND_ASSIGN (auto result, DeclarationToExecBatches (std::move (asof_join)));
1963+ auto exp_batch = ExecBatchFromJSON ({int64 (), list_type}, R"( [
1964+ [1, [0, 1, 2, 9]],
1965+ [2, [0, 1, 2, 9]],
1966+ [3, [3, 4, 5, 7]]
1967+ ])" );
1968+
1969+ AssertExecBatchesEqual (result.schema , {exp_batch}, result.batches );
1970+ }
1971+
1972+ TEST (AsofJoinTest, StructTestDataType) {
1973+ auto struct_type = struct_ ({field (" key" , utf8 ()), field (" value" , int64 ())});
1974+
1975+ auto left_batch = ExecBatchFromJSON ({int64 ()}, R"( [[1], [2], [3]])" );
1976+ auto right_batch = ExecBatchFromJSON ({struct_type, int64 ()}, R"( [
1977+ [{"key": "a", "value": 1}, 2],
1978+ [{"key": "b", "value": 3}, 3],
1979+ [{"key": "c", "value": 5}, 4]
1980+ ])" );
1981+
1982+ Declaration left{" exec_batch_source" ,
1983+ ExecBatchSourceNodeOptions (schema ({field (" on" , int64 ())}),
1984+ {std::move (left_batch)})};
1985+ Declaration right{" exec_batch_source" ,
1986+ ExecBatchSourceNodeOptions (
1987+ schema ({field (" col" , struct_type), field (" on" , int64 ())}),
1988+ {std::move (right_batch)})};
1989+ AsofJoinNodeOptions asof_join_opts ({{{" on" }, {}}, {{" on" }, {}}}, 1 );
1990+ Declaration asof_join{
1991+ " asofjoin" , {std::move (left), std::move (right)}, std::move (asof_join_opts)};
1992+ ASSERT_OK_AND_ASSIGN (auto result, DeclarationToExecBatches (std::move (asof_join)));
1993+
1994+ auto exp_batch = ExecBatchFromJSON ({int64 (), struct_type}, R"( [
1995+ [1, {"key": "a", "value": 1}],
1996+ [2, {"key": "a", "value": 1}],
1997+ [3, {"key": "b", "value": 3}]
1998+ ])" );
1999+ AssertExecBatchesEqual (result.schema , {exp_batch}, result.batches );
2000+ }
2001+
2002+ TEST (AsofJoinTest, MapTestDataType) {
2003+ auto map_type = map (int64 (), int64 ());
2004+
2005+ auto left_batch = ExecBatchFromJSON ({int64 ()}, R"( [[1], [2], [3]])" );
2006+ auto right_batch = ExecBatchFromJSON ({map_type, int64 ()}, R"( [
2007+ [[[11, 111], [22, 222]], 2],
2008+ [[[33, 333], [44, 444], [77, 777]], 3],
2009+ [[[55, 555], [66, 666]], 4]
2010+ ])" );
2011+
2012+ Declaration left{" exec_batch_source" ,
2013+ ExecBatchSourceNodeOptions (schema ({field (" on" , int64 ())}),
2014+ {std::move (left_batch)})};
2015+ Declaration right{
2016+ " exec_batch_source" ,
2017+ ExecBatchSourceNodeOptions (schema ({field (" col" , map_type), field (" on" , int64 ())}),
2018+ {std::move (right_batch)})};
2019+ AsofJoinNodeOptions asof_join_opts ({{{" on" }, {}}, {{" on" }, {}}}, 1 );
2020+ Declaration asof_join{
2021+ " asofjoin" , {std::move (left), std::move (right)}, std::move (asof_join_opts)};
2022+
2023+ ASSERT_OK_AND_ASSIGN (auto result, DeclarationToExecBatches (std::move (asof_join)));
2024+ auto exp_batch = ExecBatchFromJSON ({int64 (), map_type}, R"( [
2025+ [1, [[11, 111], [22, 222]]],
2026+ [2, [[11, 111], [22, 222]]],
2027+ [3, [[33, 333], [44, 444], [77, 777]]]
2028+ ])" );
2029+ AssertExecBatchesEqual (result.schema , {exp_batch}, result.batches );
2030+ }
19132031} // namespace acero
19142032} // namespace arrow
0 commit comments