mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 20:02:05 +00:00
Fix pointInPolygon with const 2d array
This commit is contained in:
parent
1e1b30dc05
commit
f32b7f48f1
@ -508,20 +508,35 @@ private:
|
|||||||
|
|
||||||
void parseConstPolygonFromSingleColumn(Block & block, const ColumnNumbers & arguments, Polygon & out_polygon) const
|
void parseConstPolygonFromSingleColumn(Block & block, const ColumnNumbers & arguments, Polygon & out_polygon) const
|
||||||
{
|
{
|
||||||
ColumnPtr polygon_column_float64 = castColumn(
|
|
||||||
block.getByPosition(arguments[1]),
|
|
||||||
std::make_shared<DataTypeArray>(
|
|
||||||
std::make_shared<DataTypeTuple>(DataTypes{
|
|
||||||
std::make_shared<DataTypeFloat64>(),
|
|
||||||
std::make_shared<DataTypeFloat64>()})));
|
|
||||||
|
|
||||||
const ColumnConst & column_const = typeid_cast<const ColumnConst &>(*polygon_column_float64);
|
|
||||||
const IColumn & column_const_data = column_const.getDataColumn();
|
|
||||||
|
|
||||||
if (isTwoDimensionalArray(*block.getByPosition(arguments[1]).type))
|
if (isTwoDimensionalArray(*block.getByPosition(arguments[1]).type))
|
||||||
|
{
|
||||||
|
ColumnPtr polygon_column_float64 = castColumn(
|
||||||
|
block.getByPosition(arguments[1]),
|
||||||
|
std::make_shared<DataTypeArray>(
|
||||||
|
std::make_shared<DataTypeArray>(
|
||||||
|
std::make_shared<DataTypeTuple>(DataTypes{
|
||||||
|
std::make_shared<DataTypeFloat64>(),
|
||||||
|
std::make_shared<DataTypeFloat64>()}))));
|
||||||
|
|
||||||
|
const ColumnConst & column_const = typeid_cast<const ColumnConst &>(*polygon_column_float64);
|
||||||
|
const IColumn & column_const_data = column_const.getDataColumn();
|
||||||
|
|
||||||
parseConstPolygonWithHolesFromSingleColumn(column_const_data, 0, out_polygon);
|
parseConstPolygonWithHolesFromSingleColumn(column_const_data, 0, out_polygon);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
ColumnPtr polygon_column_float64 = castColumn(
|
||||||
|
block.getByPosition(arguments[1]),
|
||||||
|
std::make_shared<DataTypeArray>(
|
||||||
|
std::make_shared<DataTypeTuple>(DataTypes{
|
||||||
|
std::make_shared<DataTypeFloat64>(),
|
||||||
|
std::make_shared<DataTypeFloat64>()})));
|
||||||
|
|
||||||
|
const ColumnConst & column_const = typeid_cast<const ColumnConst &>(*polygon_column_float64);
|
||||||
|
const IColumn & column_const_data = column_const.getDataColumn();
|
||||||
|
|
||||||
parseConstPolygonWithoutHolesFromSingleColumn(column_const_data, 0, out_polygon);
|
parseConstPolygonWithoutHolesFromSingleColumn(column_const_data, 0, out_polygon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseConstPolygon(Block & block, const ColumnNumbers & arguments, Polygon & out_polygon) const
|
void parseConstPolygon(Block & block, const ColumnNumbers & arguments, Polygon & out_polygon) const
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
1
|
||||||
|
a
|
@ -0,0 +1,14 @@
|
|||||||
|
SELECT pointInPolygon((0, 0), [[(0, 0), (10, 0), (10, 10), (0, 10)]]);
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS s;
|
||||||
|
create table s (`id` String, `lng` Int64, `lat` Int64) engine = Memory();
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS p;
|
||||||
|
CREATE TABLE p ( `polygon_id` Int64, `polygon_name` String, `shape` Array(Array(Tuple(Float64, Float64))), `state` String ) engine = Memory();
|
||||||
|
|
||||||
|
INSERT INTO s VALUES ( 'a', 0, 0 );
|
||||||
|
INSERT INTO p VALUES (8, 'a', [[(0, 0), (10, 0), (10, 10), (0, 10)]], 'a');
|
||||||
|
SELECT id FROM s WHERE pointInPolygon((lng,lat), (select shape from p where polygon_id = 8));
|
||||||
|
|
||||||
|
DROP TABLE s;
|
||||||
|
DROP TABLE p;
|
Loading…
Reference in New Issue
Block a user