From 191d8b9707527b07c772c5e91e438dfe71c3b2d3 Mon Sep 17 00:00:00 2001 From: serebrserg Date: Mon, 15 Aug 2016 18:00:02 +0300 Subject: [PATCH] METR-22322: add functional test --- dbms/include/DB/Functions/FunctionsGeo.h | 16 +++++----------- .../00362_great_circle_distance.reference | 3 +++ .../0_stateless/00362_great_circle_distance.sql | 6 ++++++ 3 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 dbms/tests/queries/0_stateless/00362_great_circle_distance.reference create mode 100644 dbms/tests/queries/0_stateless/00362_great_circle_distance.sql diff --git a/dbms/include/DB/Functions/FunctionsGeo.h b/dbms/include/DB/Functions/FunctionsGeo.h index 4d5382b6b6d..9a7cd328195 100644 --- a/dbms/include/DB/Functions/FunctionsGeo.h +++ b/dbms/include/DB/Functions/FunctionsGeo.h @@ -69,13 +69,11 @@ private: instrs_t getInstructions(const Block & block, const ColumnNumbers & arguments, bool & out_const) { instrs_t result; - out_const = true; - int arg_idx = 0; - - for (const auto arg_pos : arguments) + + for (const auto arg_idx : ext::range(0, arguments.size())) { - const auto column = block.getByPosition(arg_pos).column.get(); + const auto column = block.getByPosition(arguments[arg_idx]).column.get(); if (const auto col = typeid_cast *>(column)) { @@ -87,12 +85,8 @@ private: result[arg_idx] = instr_t{instr_type::get_const_float_64, col}; } else - { throw Exception("Illegal column " + column->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_COLUMN); - } - - ++arg_idx; } return result; @@ -148,9 +142,9 @@ private: for (const auto idx : ext::range(0, instrs.size())) { if (instr_type::get_float_64 == instrs[idx].first) - vals[idx] = static_cast *>(block.getByPosition(arguments[idx]).column.get())->getData()[row]; + vals[idx] = static_cast *>(instrs[idx].second)->getData()[row]; else if (instr_type::get_const_float_64 == instrs[idx].first) - vals[idx] = static_cast *>(block.getByPosition(arguments[idx]).column.get())->getData(); + vals[idx] = static_cast *>(instrs[idx].second)->getData(); else throw std::logic_error{"unknown instr_type"}; } diff --git a/dbms/tests/queries/0_stateless/00362_great_circle_distance.reference b/dbms/tests/queries/0_stateless/00362_great_circle_distance.reference new file mode 100644 index 00000000000..f3590f06943 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00362_great_circle_distance.reference @@ -0,0 +1,3 @@ +343417 +342558 +0 diff --git a/dbms/tests/queries/0_stateless/00362_great_circle_distance.sql b/dbms/tests/queries/0_stateless/00362_great_circle_distance.sql new file mode 100644 index 00000000000..a0fa9bb1eae --- /dev/null +++ b/dbms/tests/queries/0_stateless/00362_great_circle_distance.sql @@ -0,0 +1,6 @@ +SELECT floor(greatCircleDistance(33.3, 55.3, 38.7, 55.1)) AS distance; +SELECT floor(greatCircleDistance(33.3 + v, 55.3 + v, 38.7 + v , 55.1 + v)) AS distance from +( + select number + 0.1 as v from system.numbers limit 1 +); +SELECT floor(greatCircleDistance(33.3, 55.3, 33.3, 55.3)) AS distance;