diff --git a/src/expr/typed_value.hpp b/src/expr/typed_value.hpp index b851278cb..7c42fa2e4 100644 --- a/src/expr/typed_value.hpp +++ b/src/expr/typed_value.hpp @@ -21,6 +21,7 @@ #include #include +#include "expr/typed_value_exception.hpp" #include "utils/algorithm.hpp" #include "utils/exceptions.hpp" #include "utils/fnv.hpp" @@ -32,16 +33,6 @@ namespace memgraph::expr { -/** - * An exception raised by the TypedValue system. Typically when - * trying to perform operations (such as addition) on TypedValues - * of incompatible Types. - */ -class TypedValueException : public utils::BasicException { - public: - using utils::BasicException::BasicException; -}; - // TODO: Neo4j does overflow checking. Should we also implement it? /** * Stores a query runtime value and its type. diff --git a/src/expr/typed_value_exception.hpp b/src/expr/typed_value_exception.hpp new file mode 100644 index 000000000..bbf7463ba --- /dev/null +++ b/src/expr/typed_value_exception.hpp @@ -0,0 +1,26 @@ +// Copyright 2022 Memgraph Ltd. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source +// License, and you may not use this file except in compliance with the Business Source License. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +#pragma once + +#include "utils/exceptions.hpp" + +namespace memgraph::expr { +/** + * An exception raised by the TypedValue system. Typically when + * trying to perform operations (such as addition) on TypedValues + * of incompatible Types. + */ +class TypedValueException : public utils::BasicException { + public: + using utils::BasicException::BasicException; +}; +} // namespace memgraph::expr diff --git a/src/glue/v2/communication.cpp b/src/glue/v2/communication.cpp index 6da68950a..f14013ae0 100644 --- a/src/glue/v2/communication.cpp +++ b/src/glue/v2/communication.cpp @@ -202,46 +202,8 @@ Value ToBoltValue(msgs::Value value) { return Value{std::move(map)}; } case msgs::Value::Type::Vertex: - case msgs::Value::Type::Edge: - case msgs::Value::Type::Path: { - throw utils::BasicException("Vertex, Edge and Path are not supported!"); - } - } -} - -Value ToBoltValue(msgs::Value value, const coordinator::ShardMap & /*shard_map*/, storage::v3::View /*view*/) { - switch (value.type) { - case msgs::Value::Type::Null: - return {}; - case msgs::Value::Type::Bool: - return {value.bool_v}; - case msgs::Value::Type::Int64: - return {value.int_v}; - case msgs::Value::Type::Double: - return {value.double_v}; - case msgs::Value::Type::String: - return {std::string(value.string_v)}; - case msgs::Value::Type::List: { - std::vector values; - values.reserve(value.list_v.size()); - for (const auto &v : value.list_v) { - auto maybe_value = ToBoltValue(v); - values.emplace_back(std::move(maybe_value)); - } - return Value{std::move(values)}; - } - case msgs::Value::Type::Map: { - std::map map; - for (const auto &kv : value.map_v) { - auto maybe_value = ToBoltValue(kv.second); - map.emplace(kv.first, std::move(maybe_value)); - } - return Value{std::move(map)}; - } - case msgs::Value::Type::Vertex: - case msgs::Value::Type::Edge: - case msgs::Value::Type::Path: { - throw utils::BasicException("Vertex, Edge and Path are not supported!"); + case msgs::Value::Type::Edge: { + throw utils::BasicException("Vertex and Edge not supported!"); } } } diff --git a/src/query/v2/bindings/bindings.hpp b/src/query/v2/bindings/bindings.hpp index 42b72424c..13e80d437 100644 --- a/src/query/v2/bindings/bindings.hpp +++ b/src/query/v2/bindings/bindings.hpp @@ -11,5 +11,9 @@ #pragma once +#ifdef MG_AST_INCLUDE_PATH +#error You are probably trying to include files from expr from both the storage and query engines! You will have a rough time kid! +#endif + #define MG_AST_INCLUDE_PATH "query/v2/frontend/ast/ast.hpp" // NOLINT(cppcoreguidelines-macro-usage) #define MG_INJECTED_NAMESPACE_NAME memgraph::query::v2 // NOLINT(cppcoreguidelines-macro-usage) diff --git a/src/query/v2/conversions.hpp b/src/query/v2/conversions.hpp index 9556d789c..1f8446656 100644 --- a/src/query/v2/conversions.hpp +++ b/src/query/v2/conversions.hpp @@ -50,8 +50,6 @@ inline TypedValue ValueToTypedValue(const msgs::Value &value) { return TypedValue(accessors::VertexAccessor(value.vertex_v, {})); case Value::Type::Edge: return TypedValue(accessors::EdgeAccessor(value.edge_v, {})); - case Value::Type::Path: - break; } throw std::runtime_error("Incorrect type in conversion"); } @@ -91,7 +89,10 @@ inline msgs::Value TypedValueToValue(const TypedValue &value) { case TypedValue::Type::Edge: return Value(value.ValueEdge().GetEdge()); case TypedValue::Type::Path: - default: + case TypedValue::Type::LocalTime: + case TypedValue::Type::LocalDateTime: + case TypedValue::Type::Date: + case TypedValue::Type::Duration: break; } throw std::runtime_error("Incorrect type in conversion"); diff --git a/src/query/v2/plan/operator.lcp b/src/query/v2/plan/operator.lcp index 154adf753..d6277809c 100644 --- a/src/query/v2/plan/operator.lcp +++ b/src/query/v2/plan/operator.lcp @@ -22,9 +22,9 @@ #include #include +#include "expr/semantic/symbol.hpp" #include "query/v2/common.hpp" #include "query/v2/frontend/ast/ast.hpp" -#include "expr/semantic/symbol.hpp" #include "query/v2/bindings/typed_value.hpp" #include "query/v2/bindings/frame.hpp" #include "query/v2/bindings/symbol_table.hpp" diff --git a/src/query/v2/requests.hpp b/src/query/v2/requests.hpp index 8d30c21f8..4b2588c24 100644 --- a/src/query/v2/requests.hpp +++ b/src/query/v2/requests.hpp @@ -76,16 +76,6 @@ struct Vertex { friend bool operator==(const Vertex &lhs, const Vertex &rhs) { return lhs.id == rhs.id; } }; -struct PathPart { - Vertex dst; - Gid edge; -}; - -struct Path { - Vertex src; - std::vector parts; -}; - struct Null {}; struct Value { @@ -135,13 +125,9 @@ struct Value { case Type::Map: std::destroy_at(&map_v); return; - case Type::Vertex: std::destroy_at(&vertex_v); return; - case Type::Path: - std::destroy_at(&path_v); - return; case Type::Edge: std::destroy_at(&edge_v); } @@ -175,9 +161,6 @@ struct Value { case Type::Edge: new (&edge_v) Edge(other.edge_v); return; - case Type::Path: - new (&path_v) Path(other.path_v); - return; } } @@ -209,9 +192,6 @@ struct Value { case Type::Edge: new (&edge_v) Edge(std::move(other.edge_v)); break; - case Type::Path: - new (&path_v) Path(std::move(other.path_v)); - break; } other.DestroyValue(); @@ -251,9 +231,6 @@ struct Value { case Type::Edge: new (&edge_v) Edge(other.edge_v); break; - case Type::Path: - new (&path_v) Path(other.path_v); - break; } return *this; @@ -292,9 +269,6 @@ struct Value { case Type::Edge: new (&edge_v) Edge(std::move(other.edge_v)); break; - case Type::Path: - new (&path_v) Path(std::move(other.path_v)); - break; } other.DestroyValue(); @@ -302,7 +276,7 @@ struct Value { return *this; } - enum class Type : uint8_t { Null, Bool, Int64, Double, String, List, Map, Vertex, Edge, Path }; + enum class Type : uint8_t { Null, Bool, Int64, Double, String, List, Map, Vertex, Edge }; Type type{Type::Null}; union { Null null_v; @@ -314,7 +288,6 @@ struct Value { std::map map_v; Vertex vertex_v; Edge edge_v; - Path path_v; }; friend bool operator==(const Value &lhs, const Value &rhs) { @@ -340,8 +313,6 @@ struct Value { return lhs.vertex_v == rhs.vertex_v; case Value::Type::Edge: return lhs.edge_v == rhs.edge_v; - case Value::Type::Path: - return true; } } }; @@ -381,18 +352,22 @@ struct ScanVerticesRequest { Hlc transaction_id; VertexId start_id; std::optional> props_to_return; + // expression that determines if vertex is returned or not + std::vector filter_expressions; + // expression whose result is returned for every vertex + std::vector vertex_expressions; std::optional batch_limit; StorageView storage_view{StorageView::NEW}; std::optional