Skip to content

Commit

Permalink
Merge branch 'master' into yield_fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 authored Oct 22, 2021
2 parents 71e0224 + cd2ecb9 commit 3a8bffc
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/common/datatypes/Geography.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,30 @@

namespace nebula {

std::ostream& operator<<(std::ostream& os, const GeoShape& shape) {
switch (shape) {
case GeoShape::POINT: {
os << "POINT";
break;
}
case GeoShape::LINESTRING: {
os << "LINESTRING";
break;
}
case GeoShape::POLYGON: {
os << "POLYGON";
break;
}
case GeoShape::UNKNOWN:
default: {
os << "__UNKNOWN__";
break;
}
}

return os;
}

constexpr double kMaxLongitude = 180.0;
constexpr double kMaxLatitude = 90.0;

Expand Down
2 changes: 2 additions & 0 deletions src/common/datatypes/Geography.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ enum class GeoShape : uint32_t {
POLYGON = 3,
};

std::ostream& operator<<(std::ostream& os, const GeoShape& shape);

// clang-format off
/*
static const std::unordered_map<GeoShape, S2Region> kShapeTypeToS2Region = {
Expand Down
12 changes: 11 additions & 1 deletion src/meta/processors/schema/SchemaUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,23 @@ bool SchemaUtil::checkType(std::vector<cpp2::ColumnDef>& columns) {
return false;
}
break;
case cpp2::PropertyType::GEOGRAPHY:
case cpp2::PropertyType::GEOGRAPHY: {
if (!value.isGeography()) { // TODO(jie)
LOG(ERROR) << "Invalid default value for ` " << name << "', value type is "
<< value.type();
return false;
}
meta::cpp2::GeoShape columnGeoShape =
column.get_type().geo_shape_ref().value_or(meta::cpp2::GeoShape::ANY);
GeoShape defaultExprGeoShape = value.getGeography().shape();
if (columnGeoShape != meta::cpp2::GeoShape::ANY &&
folly::to<uint32_t>(columnGeoShape) != folly::to<uint32_t>(defaultExprGeoShape)) {
LOG(ERROR) << "Invalid default value for ` " << name << "', value type is "
<< value.type() << ", geo shape is " << defaultExprGeoShape;
return false;
}
break;
}
default:
LOG(ERROR) << "Unsupported type";
return false;
Expand Down
42 changes: 42 additions & 0 deletions tests/tck/features/geo/GeoBase.feature
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,48 @@ Feature: Geo base
Then the result should be, in any order:
| Tag | Create Tag |
| "only_point" | 'CREATE TAG `only_point` (\n `geo` geography(point) NULL\n) ttl_duration = 0, ttl_col = ""' |
# Test default property value
When executing query:
"""
CREATE TAG test_1(geo geography DEFAULT ST_Point(3, 8));
"""
Then the execution should be successful
When executing query:
"""
CREATE EDGE test_2(geo geography DEFAULT ST_GeogFromText("LINESTRING(0 1, 2 3)"));
"""
Then the execution should be successful
When executing query:
"""
CREATE EDGE test_2(geo geography DEFAULT ST_GeogFromText("LINESTRING(0 1, 2xxxx"));
"""
Then a ExecutionError should be raised at runtime: Invalid parm!
When executing query:
"""
CREATE TAG test_3(geo geography(point) DEFAULT ST_GeogFromText("LineString(0 1, 2 3)"));
"""
Then a ExecutionError should be raised at runtime: Invalid parm!
When executing query:
"""
CREATE TAG test_3(geo geography(linestring) DEFAULT ST_GeogFromText("LineString(0 1, 2 3)"));
"""
Then the execution should be successful
And wait 3 seconds
When executing query:
"""
INSERT VERTEX test_1() VALUES "test_101":()
"""
Then the execution should be successful
When executing query:
"""
INSERT EDGE test_2() VALUES "test_101"->"test_102":()
"""
Then the execution should be successful
When executing query:
"""
INSERT VERTEX test_3() VALUES "test_103":()
"""
Then the execution should be successful

Scenario: test geo CURD
# Any geo shape(point/linestring/polygon) is allowed to insert to the column geography
Expand Down

0 comments on commit 3a8bffc

Please sign in to comment.